Skip to content

Commit

Permalink
 add deployment/connection management docs for lambds
Browse files Browse the repository at this point in the history
  • Loading branch information
nikolasburk committed Dec 19, 2019
1 parent 973ef07 commit b6426a9
Showing 1 changed file with 34 additions and 1 deletion.
35 changes: 34 additions & 1 deletion docs/photon/deployment.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ The query engine binary is downloaded when you run `prisma2 generate`, it is the

**IMPORTANT**: To ensure the query engine binary is compatible with your production environment, you have to [specify the right platform for Photon.js](../core/generators/photonjs.md#specifying-the-right-platform-for-photon-js).

## Photon in FaaS environment (e.g. AWS Lambda, Netlify)
## Photon in FaaS environment (e.g. AWS Lambda, Netlify, ...)

### Database connection handling

Expand Down Expand Up @@ -51,6 +51,39 @@ Here are a number of example projects demonstrating how to deploy Photon.js to v

## Deployment providers

### AWS Lambda

In order to not exhaust the connection limits of your database, you should set the `connection_limit` parameter of your database connection string in the Prisma schema to `1` when deploying your Photon.js-based application to [AWS Lambda]().

**PostgreSQL**

```
postgresql://USER:PASSWORD@HOST:PORT/DATABASE?connection_limit=1
```

**MySQL**

```
mysql://USER:PASSWORD@HOST:PORT/DATABASE?connection_limit=1
```

Note that depending on your Lambda concurrency limit, you might still exhaust your database's connection limit. This can happen when too many Lambdas are invoked concurrently (i.e. the number of concurrent Lambdas that each hold a DB connection exceeds the connection limit of your database). To prevent this, you should [set your Lambda concurrency limit](https://docs.aws.amazon.com/lambda/latest/dg/configuration-concurrency.html) to number that represents the connection limit of your database.

| Instance size | Connection limit |
| :----------- | :------------ |
| t2.micro | 77 |
| t2.small | 188 |
| t2.medium | 403 |
| t2.large | 846 |
| t2.xlarge | 1733 |
| t2.2xlarge | 3508 |
| m5.large | 813 |
| m5.xlarge | 1681 |
| m5.2xlarge | 3419 |
| m5.4xlarge | 4990 |

This means that if you're e.g. using a `m5.large` PostgreSQL instance, you need to set your Lambda concurrency limit to `813`.

### ZEIT Now

You can deploy your "Photon.js"-based application to [ZEIT Now](https://zeit.co/now).
Expand Down

0 comments on commit b6426a9

Please sign in to comment.