Skip to content

Commit

Permalink
Merge pull request #311 from Genez-io/add-long-running-documentation
Browse files Browse the repository at this point in the history
Add persistent/long-running docs
  • Loading branch information
andreia-oca authored Feb 19, 2025
2 parents 76c14a3 + d1c686a commit 789f60e
Show file tree
Hide file tree
Showing 3 changed files with 75 additions and 1 deletion.
60 changes: 60 additions & 0 deletions docs/deploy/persistent.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
---
description: Genezio offers seamless application deployments. Deploy a long-running backend service with a single command `genezio deploy`.
---

# Persistent (Long-Running) Server

Genezio supports deploying persistent or long-running servers, ensuring that your application remains active without scaling down to zero.
This is particularly useful for applications that require continuous processing or stateful operations.


## What is a Persistent Server?

A persistent or long-running server is an application that stays active and does not automatically scale down to zero when there are no incoming requests.
Unlike serverless functions that are event-driven and ephemeral, persistent servers allow for stateful operations and long-running tasks.

## Deploy Persistent Server in Genezio

To deploy a persistent server on Genezio, you need to define the function type as persistent in your genezio.yaml configuration file.

Here's an example of a genezio.yaml configuration file with a persistent function:

```yaml
name: my-project
region: us-east-1
yamlVersion: 2
backend:
path: .
language:
name: js
functions:
- name: persistent-server
path: .
entry: server.mjs
handler: handler
type: persistent
```
Once you have configured the `genezio.yaml` file, you can either commit it to your GitHub repository or deploy it directly using the Genezio CLI:

```bash
genezio deploy
```

Genezio will provision the necessary resources to ensure that your server remains running continuously.

After deploying, you can send requests to your server using the generated endpoint URL available in the Genezio dashboard or in the CLI output.

:::tip info
To send requests to your persistent server, do not forget to prepend `compute-` to the endpoint URL.
The format should be `https://compute-<server-uuid>.<region>.cloud.genez.io`.
:::

Note: Sending requests to the URL `https://<server-uuid>.<region>.cloud.genez.io` will trigger a serverless call instead of a persistent server call.

## Enterprise Support

Persistent servers are available as an Enterprise-only feature.
If you are interested in deploying a persistent server on Genezio, please [contact us](mailto:[email protected]) for more information.

For further details on server types and configurations, refer to the [Genezio Configuration File](/docs/project-structure/genezio-configuration-file.md).
15 changes: 14 additions & 1 deletion docs/project-structure/genezio-configuration-file.md
Original file line number Diff line number Diff line change
Expand Up @@ -419,10 +419,11 @@ This resource exposes `url` as an output expression: `${{backend.functions.<func

- `type`: `string` **Optional**

The type of the function. This can be `aws` or `httpServer`. If this field is not specified, the default value is `aws`.
The type of the function. This can be: `aws`, `httpServer`, or `persistent`. If this field is not specified, the default value is `aws`.

- `aws` indicates that the function will be deployed as an AWS Lambda handler. This means that the function is either a Lambda event handler or it uses [`serverless-http`](https://www.npmjs.com/package/serverless-http) to convert an Express app to a Lambda event handler.
- `httpServer` indicates that the function will be deployed as a standalone HTTP server, such as those built with frameworks like `express`, `fastify`, `flask`, `django`, etc.
- `persistent` indicates that the function will be deployed as a long-running server that will not be scaled down to 0. This is an Enterprise-only feature, please [contact us](mailto:[email protected]) for more information.

Note 1: The recommended way to deploy your app is to use the `httpServer` type unless you are explicitly migrating from an existing AWS Lambda function or using `serverless-http`.
Note 2: Websocket are supported only for `httpServer` functions.
Expand Down Expand Up @@ -821,6 +822,12 @@ The Docker container configuration. This field can be omitted if the project is

For larger values, [contact us](mailto:[email protected]).

- `type`: `string` **Optional**

The type of the container can be set to `persistent`. If this field is not specified, the container will be deployed in a serverless manner.

- `persistent` indicates that the container will be deployed as a long-running server that will not be scaled down to 0. This is an Enterprise-only feature, please [contact us](mailto:[email protected]) for more information.

### Example of `container` deployment configuration

```yaml
Expand Down Expand Up @@ -950,6 +957,12 @@ Variables can be used in the scripts. Check the [Usage](#variables) section for

For custom runtimes, please [contact us](mailto:[email protected]).

- `type`: `string` **Optional**

The type of the server can be set to `persistent`. If this field is not specified, the server will be deployed in a serverless manner.

- `persistent` indicates that the server will be deployed as long-running and it will not be scaled down to 0. This is an Enterprise-only feature, please [contact us](mailto:[email protected]) for more information.

### Example of `nextjs` deployment configuration

This example can be easily used for Nuxt.js, Nitro, Nestjs, Remix, or Streamlit projects by changing the `nextjs` field to `nuxt`, `nitro`, `nestjs`, `remix`, or `streamlit`.
Expand Down
1 change: 1 addition & 0 deletions sidebars.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ const sidebars = {
items: [
"deploy/backend",
"deploy/frontend",
"deploy/persistent",
"deploy/serverless-containers",
],
},
Expand Down

0 comments on commit 789f60e

Please sign in to comment.