Skip to content

Commit 1f62a20

Browse files
Docs for configuring app servers for production (#3120)
Co-authored-by: José Valim <[email protected]>
1 parent d1c9f13 commit 1f62a20

File tree

3 files changed

+42
-0
lines changed

3 files changed

+42
-0
lines changed
50.1 KB
Loading
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# Configuring app servers for production
2+
3+
This guide covers recommended configurations for running Livebook app servers in production environments.
4+
5+
## Persisting compiled dependencies
6+
7+
Livebook notebooks can declare Hex dependencies using `Mix.install/2`. When a notebook runs, Mix compiles these dependencies and caches them in a configurable directory. By default, this directory is not persistent in containerized environments, so dependencies must be recompiled every time the container restarts, increasing startup time for deployed apps.
8+
9+
To persist compiled dependencies across container restarts, mount a persistent volume and configure the following environment variable:
10+
11+
```
12+
MIX_INSTALL_DIR=/data
13+
```
14+
15+
Where `/data` is the mount point of your persistent volume.
16+
17+
This reduces app startup time after container restarts since dependencies don't need to be recompiled.
18+
19+
## Memory sizing
20+
21+
App servers require memory for the Livebook runtime itself plus each app session. Use this formula as a rule of thumb to calculate the recommended memory:
22+
23+
```text
24+
Total memory = 1.5 GB (base) + (50 MB × number of app sessions)
25+
```
26+
27+
The base 1.5 GB accommodates the Livebook web server and the memory required during `Mix.install/2`commands. Each app session requires approximately 50 MB, though this can vary depending on the app. For single-session apps, this equals one session per app. Multi-session apps will use 50 MB per session.
28+
29+
This calculation assumes all apps have active sessions running simultaneously, representing peak memory usage.
30+
31+
**Example:** For 70 single-session apps:
32+
33+
```text
34+
1.5 GB + (70 × 50 MB) = 1.5 GB + 3.5 GB = 5 GB
35+
```
36+
37+
> #### Reduce memory usage with inactivity shutdown {: .tip}
38+
>
39+
> Configure "Shutdown after inactivity" in the app settings to automatically stop idle sessions. This frees memory when sessions are not in use.
40+
>
41+
> ![](images/shutdown-inactivity.png)

mix.exs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,7 @@ defmodule Livebook.MixProject do
266266
{"docs/teams/deploy_via_cli.md", title: "Deploy Livebook apps via CLI"},
267267
"docs/teams/deploy_permissions.md",
268268
{"docs/teams/app_folders.md", title: "Organize apps with folders"},
269+
{"docs/teams/app_server_production.md", title: "Production app servers"},
269270
{"docs/teams/email_domain.md", title: "Email domain auth"},
270271
{"docs/teams/oidc_sso.md", title: "OIDC SSO"},
271272
"docs/teams/oidc_groups.md",

0 commit comments

Comments
 (0)