Serverless vs. Persistent Servers
Leapcell offers two primary deployment modes to cater to diverse application needs: Serverless (Pay-as-you-go) and Persistent (Charge-by-time).
On Leapcell, your service can switch between Serverless and Persistent Server modes at any time. You can choose the mode that best fits your specific use case.
Understanding their distinct features and trade-offs will help you choose the most suitable option for your project.
Serverless (Pay-as-you-go)

The Serverless mode is an event-driven computing model where you only pay for the time your code is actively running.
Billing starts when a request is received and ends once the request has been fully processed. You incur no costs for idle time when your application is not serving traffic.

Automatic Scaling
The platform automatically scales the number of instances up or down based on traffic volume.
It can scale to thousands of instances to effortlessly handle traffic spikes.

Cold Starts
If your service receives no traffic for a period (e.g., 30 minutes), its instances may go dormant. A new incoming request will trigger a "cold start" to provision a new instance, which can add a latency of up to 250ms. Services with consistent traffic rarely encounter this.

Serverless Advantages and Limitations
Key Advantages
Advantage | Description |
---|---|
Cost-Effective | Eliminates charges for idle resources, making it ideal for applications with variable or unpredictable traffic patterns. |
Automatic Scaling | The platform automatically scales the number of instances up or down based on traffic volume. It can scale to thousands of instances to effortlessly handle traffic spikes. |
Limitations to Consider
Limitation | Description |
---|---|
HTTP Short-Lived Requests Only | The Serverless model is optimized for short-lived HTTP requests. It is not suitable for long-running connections such as WebSockets, long-polling, or background jobs. |
Temporary File System | Only the /tmp directory is writable. All other paths in the file system are read-only. |
Request Timeout | The maximum execution time for a single request is 15 minutes. |
CPU Suspension | During idle periods, the instance's CPU is suspended. This means it cannot run any background tasks when there are no incoming requests. |
Persistent Mode (Charge-by-time)

The Persistent mode provides you with a dedicated, continuously running instance, much like a local machine or a traditional cloud server.
It remains active and ready to serve traffic at all times, regardless of inbound request volume. This mode is billed based on a fixed time interval, such as per hour or per month.
Key Advantages:
Feature | Description |
---|---|
Cheaper per Unit Time | The fixed billing model can be more cost-effective for applications with steady workloads. For more details, see Leapcell Pricing. |
No Cold Starts | The instance is always active, ensuring the lowest possible latency for every request. |
File System | Offers a writable file system beyond the /tmp directory, allowing for local file I/O, caching, and state management. |
Long-Running Tasks | Ideal for processes that need to run for extended periods without being suspended, such as background jobs, data processing, or maintaining persistent connections (e.g., WebSockets). |
Serverless or Persistent for my use case?
For most use cases, we recommend starting with the Serverless mode due to its excellent flexibility and cost efficiency.
When to Use Serverless
When to Use Serverless | Description |
---|---|
Any stateless HTTP or web service | Your application state should be stored in object storage or a database, not in the service itself. |
Services with unpredictable early-stage traffic | In the early stage, when traffic is low or uncertain, the Serverless model is the most cost-efficient choice. |
When to Use Persistent Servers
The Persistent mode is the superior choice in the following scenarios:
When to Use Persistent Servers | Description |
---|---|
High and Sustained Traffic | If your service consistently handles high traffic, the cost-per-hour of a Persistent instance may be lower than the cumulative cost of frequent Serverless invocations. |
Long-Running Background Jobs | For tasks that exceed the 15-minute limit, such as video encoding, complex data analysis, or training machine learning models. |
Dependency on Local File System | When your application requires persistent local storage beyond /tmp , such as for caching or state management. |
Ultra-Low Latency Requirements | Ideal for applications where even minimal latency from occasional cold starts is unacceptable. |
WebSockets or Long-Lived Connections | If your service requires WebSockets or other long-lived connections, you must use Persistent Servers. |