This article is for the person who sets up atima for a lab, a
department or the public: one server that many people use from their
browsers, each signed in to their own account. It walks through the
container setup that is kept in the deploy/ folder of the
repository: the atima
server, a reverse proxy (Caddy) in front of it for HTTPS and rate
limits, and a nightly backup. To use atima alone on your own computer
you need none of this; see Using atima on
your own computer.
Everything here was built and run on one development machine with Docker Desktop. It has not yet been run on a public server, with a real certificate, or with a real sign-in provider.
What you need
- A Linux machine with Docker Engine and its Compose plugin. Four CPU cores and 8 GB of memory are a reasonable start; see How large a server.
- A host name for the server (for example
atima.example.org) that points at the machine, with ports 80 and 443 reachable from the internet, so that Caddy can get a certificate from Let’s Encrypt. If your institution puts its own proxy in front, see Behind another proxy. - A registration with a sign-in provider: a client id and a client secret. Setting up sign-in explains how to get them from Globus Auth or ORCID. You can start without them and try the server as a guest.
- Disk space for the data: the database is small; each uploaded dataset is stored once, as a file of at most the upload limit (50 MB by default). Backups should go to a different disk.
The pieces
deploy/compose.yaml starts three containers:
| Container | What it does |
|---|---|
atima |
The atima server: one R process that answers requests and owns the database, and its worker processes, which do the computing. Runs as an unprivileged user on a read-only file system. Listens on port 8080 inside the Docker network only. |
caddy |
Caddy with the rate-limit module. Gets and renews the TLS certificate, passes requests on to atima, tells atima the truth about each request (HTTPS or not, the visitor’s address), and limits how often one address may call the expensive routes. |
backup |
The same image as atima, running a loop that makes a
backup every night. |
and keeps data in Docker volumes:
| Volume | Mounted at | Holds |
|---|---|---|
atima_data |
/var/lib/atima |
The database (sqlite.db), the stored data files
(files/), and a cache that can be deleted at any time
(cache/). This is what must not be
lost.
|
atima_temp |
/var/tmp/atima |
Figures and exports waiting to be downloaded. The server deletes them after a day. |
atima_backup |
/backup |
The backups, unless you point ATIMA_BACKUP_DIR
somewhere better. |
caddy_data, caddy_config
|
Caddy’s certificates and state. |
Every setting is an environment variable. They are read from the file
deploy/.env, which you make from
deploy/.env.example and which is not in git. No file in the
repository needs editing, and no secret belongs in one.
A trial run on your own machine
This starts the whole stack on http://localhost, without
a certificate and without a sign-in provider. You can use it as a
guest.
git clone https://github.com/cmmr/atima.git
cd atima/deploy
cp .env.example .env
docker compose up -d --buildThe first build downloads R and about 150 packages and takes ten to
fifteen minutes; the image is about 2.7 GB. Later builds reuse most of
it. When the command returns, check that the three containers are up and
that atima is “healthy”:
Then open http://localhost. The two example projects are there,
and you can upload a file. “Sign in” will not work yet: the example
.env has a placeholder where the client id and secret
go.
To try signing in before you have registered with a provider, the repository has a mock provider that signs anyone in under any name they type. It is for a test on your own machine only:
To stop the trial and delete its data:
Setting up the real server
Edit deploy/.env. The settings that every server
needs:
ATIMA_SITE_ADDRESS=atima.example.org
ATIMA_PUBLIC_URL=https://atima.example.org
ATIMA_OIDC_CLIENT_ID=<client id from the provider>
ATIMA_OIDC_CLIENT_SECRET=<client secret from the provider>
ATIMA_OPERATOR=the Example Lab at Example University
ATIMA_CONTACT=atima@example.org
ATIMA_BACKUP_DIR=/mnt/backup/atima-
ATIMA_SITE_ADDRESSis what Caddy serves. A bare host name means HTTPS with a certificate from Let’s Encrypt. -
ATIMA_PUBLIC_URLis the address people type. The sign-in provider sends people back to<ATIMA_PUBLIC_URL>/auth/callback, and that exact address is what you register with the provider. -
ATIMA_OPERATORandATIMA_CONTACTare shown on the app’s “Privacy and terms” page: who runs this server, and an email address or web page for questions. -
ATIMA_BACKUP_DIRis a directory on the host for the backups, on a different disk from the data or on a network share. It must be writable by user id 10001, the user the containers run as:sudo chown 10001 /mnt/backup/atima.
Keep .env readable by you alone
(chmod 600 .env): it holds the client secret. If you use
Docker secrets or another secret store instead, give the
atima container ATIMA_OIDC_CLIENT_SECRET_FILE,
the path of a file that holds the secret, in place of
ATIMA_OIDC_CLIENT_SECRET.
Then start it:
Once the site works over HTTPS, add
ATIMA_HSTS=max-age=31536000 to .env and run
docker compose up -d again. Browsers that have visited will
then refuse to use the site without HTTPS for a year.
All settings
The settings of atima::run() are described in its help
page; each is the environment variable ATIMA_<NAME>.
deploy/compose.yaml passes these on from
.env:
In .env
|
Default | Meaning |
|---|---|---|
ATIMA_SITE_ADDRESS |
What Caddy serves: a host name (HTTPS),
http://localhost (trial), or :80 (behind
another proxy). |
|
ATIMA_PUBLIC_URL |
The address people type, with https:// and no
path. |
|
ATIMA_OIDC_ISSUER |
https://auth.globus.org |
The sign-in provider. |
ATIMA_OIDC_CLIENT_ID,
ATIMA_OIDC_CLIENT_SECRET
|
From the provider. | |
ATIMA_ADMINS |
none | Administrators, by the provider’s identifier for them, separated by commas. |
ATIMA_OPERATOR, ATIMA_CONTACT
|
none | Shown on the “Privacy and terms” page. |
ATIMA_CPUS |
every core the container has | CPU cores the server may use, its own process and its jobs together. One fewer than this many jobs run at once. |
ATIMA_TIME_LIMIT |
60 | Seconds a job may run. |
ATIMA_JOBS_PER_USER |
16 | Jobs one account may have waiting or running. |
ATIMA_MAX_UPLOAD_MB |
50 | Largest upload. Caddy enforces the same number. |
ATIMA_CACHE_SIZE_MB |
100 | Size of the cache of computed results. |
ATIMA_SESSION_HOURS, ATIMA_GUEST_DAYS,
ATIMA_SIGNIN_DAYS
|
24, 30, 30 | How long an idle tab, a guest and a sign-in last. |
ATIMA_TRASH_DAYS |
30 | How long a deleted project can still be restored. |
ATIMA_MCP_WRITES |
true | May AI apps change data, for people who let them? false
offers reading and analysing only. See AI
apps. |
ATIMA_APP_DAYS |
30 | An AI app stays connected until it has not been used for this many days. |
ATIMA_APP_CHANGES_PER_HOUR |
60 | The most changes one connected AI app may make in an hour. |
ATIMA_USAGE |
true | Record how the server is used, for the administrators’ Usage page. |
ATIMA_USAGE_MONTHS |
25 | Months the record of single actions and visits is kept. |
ATIMA_GEO_DIR, ATIMA_GEO_DB
|
none | The directory of lookup files, and the files in it; see Usage. |
ATIMA_TRUSTED_PROXIES |
none | Only behind another proxy. |
ATIMA_HSTS |
off |
max-age=31536000 once HTTPS works. |
ATIMA_HTTP_PORT, ATIMA_HTTPS_PORT
|
80, 443 | The host’s ports for Caddy. |
ATIMA_BACKUP_DIR |
a Docker volume | Where backups go. |
ATIMA_BACKUP_HOUR, ATIMA_BACKUP_DAILY,
ATIMA_BACKUP_WEEKLY,
ATIMA_BACKUP_UPGRADES
|
8, 7, 4, 3 | See Backups. |
ATIMA_LIMIT_... |
See Rate limits. |
Administrators and the public projects
An administrator can edit and unpublish any public project and arranges the public list: on the Projects page, administrators see controls to create, rename, move and delete the collections (folders) that public projects are listed under, and to move public projects between them. Administrators cannot open other people’s private projects.
To make someone an administrator, have them sign in once, then find the provider’s identifier for them:
docker compose exec atima Rscript -e 'con <- DBI::dbConnect(RSQLite::SQLite(), "/var/lib/atima/sqlite.db"); print(DBI::dbGetQuery(con, "SELECT full_name, sub FROM users WHERE is_guest = 0"))'Put the sub values, separated by commas, in
ATIMA_ADMINS in .env, run
docker compose up -d, and have them sign in again. From
then on ATIMA_ADMINS decides who is an administrator, at
every sign-in.
A new server shows two example projects from rbiom. Anyone who is signed in and can edit a project can publish it, under a short name of their choosing, and public projects are not reviewed before they appear; the “Privacy and terms” page says so. To add example datasets of your own, sign in, upload them, and publish them.
AI apps
People can connect an AI app (Claude, ChatGPT and others that speak
the Model Context
Protocol) to their account, and have it explore their projects, run
statistics and draw figures, and, if they allow it, upload, change,
share, publish and delete projects. Connecting an
AI app is the article for the people who use the server; this
section is what you need to know to run it. There is nothing to switch
on: the endpoint is <public address>/mcp.
How an app gets in. atima is the OAuth 2.1
authorization server for its own /mcp endpoint, as the MCP
specification describes. An app’s first request is answered 401 with a
pointer to /.well-known/oauth-protected-resource/mcp; from
there the app finds
/.well-known/oauth-authorization-server, sends the person’s
browser to /oauth/authorize, and exchanges the code it is
returned with at /oauth/token. The person signs in through
your sign-in provider exactly as in the browser, then sees atima’s own
approval page and chooses whether the app may only read, or may also
change things. Nothing is registered with your sign-in provider for
this, and the provider never hears of the app.
Which apps. Any app may ask. An app names itself
with a Client ID Metadata Document: an https:// address
that atima fetches (once an hour at most per app) to learn the app’s
name and the addresses it may return people to. To keep that from being
used to make your server call computers inside your own network, atima
refuses addresses that are not https, that resolve to
private, loopback or link-local addresses, and follows no redirects.
The server therefore needs to be able to make outgoing HTTPS
requests to the internet, and to resolve names. If your network
only lets it out through a proxy, set https_proxy for the
atima service. An app is a “public client”: there are no
client secrets, and Dynamic Client Registration is not offered.
What is stored. A connection is a row of
app_grants (the person, the app’s name and address, what it
may do, when it was last used). Its tokens are stored as SHA-256 only.
An access token lasts an hour; the refresh token is replaced each time
it is used, and one that is used twice ends the connection. A connection
that is not used for ATIMA_APP_DAYS ends by itself. Every
change an app makes is a row of app_changes, which the
person can read under “Connected apps” and which is kept for a year. All
of it is in the database, so it is in your backups.
Switching changes off.
ATIMA_MCP_WRITES=false offers every app the six tools that
read and compute and nothing else, and removes the second choice from
the approval page. Apps that were approved for changes before lose those
tools at once.
Hosted apps reach you from the internet. A chat
website’s requests come from its maker’s servers, not from the person’s
computer. For those apps the server must be reachable from the internet,
over HTTPS, on port 443, at the address in
ATIMA_PUBLIC_URL, and so must the two
/.well-known/ documents and /oauth/token.
Anthropic publishes the address ranges Claude connects from, if your
firewall needs a list. A server that is only reachable inside your
institution works with apps that run on people’s own computers, such as
Claude Code.
What an administrator cannot see. Tool calls are
logged by tool name only (rpc in a request
line), never with their arguments, and tokens and upload tickets are
never logged. Changes are logged as app_change lines with
the tool and the numbers of the user and the project.
Not yet tried: a hosted app against a public server, and an app’s own exchange of its code for tokens. Against a test server with a stand-in sign-in provider, Claude Code found its way from the 401 to the approval page under its own identity and was returned to with a code; the exchange was then made by a script, and Claude Code used the resulting tokens for every tool, in both protocol revisions.
What Caddy does, and why
The configuration is deploy/caddy/Caddyfile. You should
not need to change it, but if you use a different proxy, this is the
list to reproduce.
-
Passes everything on.
/api/(the app’s requests),/auth/(the way to and from the sign-in provider),/www/(the app’s own files),/tmp/(figures and exports),/mcp(for AI apps),/oauth/and/.well-known/(where AI apps sign in), and the pages and downloads at/<project key>and/<project key>/<file>. -
Says whether the visitor used HTTPS, and from which
address. Caddy sets
X-Forwarded-Proto,X-Forwarded-For,X-Forwarded-HostandX-Real-IPitself on every request and discards what the visitor sent under those names. atima is told to believeX-Forwarded-Proto(ATIMA_FORWARDED_PROTO_HEADER, set incompose.yaml). A proxy that passed a visitor’s ownX-Forwarded-Protothrough would let them switch off the cookie’sSecureflag for their own session. atima takes the visitor’s address fromX-Real-IP(ATIMA_CLIENT_IP_HEADER, also set incompose.yaml): it is the address a tab’s session is stored with, and the one whose country and network the Usage page counts. If the header named there lists several addresses, asX-Forwarded-Fordoes, atima reads the last one, which is the one your proxy added. -
Does not cache. atima sends its own files with
Cache-Control: no-cache, so that browsers ask before reusing a script and never run old scripts against an upgraded server. A proxy may answer those “has it changed?” requests, but must not keep/wwwfiles longer than that. -
Does not buffer or compress
/mcp. Answers there are passed on the moment they are ready. - Refuses uploads over the limit before they reach atima.
- Limits rates (below).
-
Writes no access log. Request paths contain the
keys that give access to private projects (
/<key>), so a proxy’s access log would hold them. atima’s own log records each request by its route, without the key.
The page atima serves sets a Content-Security-Policy that allows nothing from other sites, and loads nothing from other sites. If your proxy adds a policy of its own, both apply: check that figures, fonts and the CSV download of a statistics table still work.
Rate limits
Limits are per visitor address and per minute. They protect the
routes that cost the server something before any account is involved.
Inside atima, each account is also limited to
ATIMA_JOBS_PER_USER jobs waiting or running at once; a
request over that gets status 429 and a message to wait.
| Setting | Default | Applies to | Why |
|---|---|---|---|
ATIMA_LIMIT_SESSION_INIT |
120 | POST /api/session/init |
Each call from a new browser makes a guest account. |
ATIMA_LIMIT_SIGNIN |
30 | /auth/ |
Each sign-in is remembered for ten minutes and calls the provider. |
ATIMA_LIMIT_LEGACY |
10 |
POST /api/legacy/list,
/api/legacy/start
|
Checking an old password takes a worker about a second. |
ATIMA_LIMIT_DOWNLOADS |
60 | GET /<key>/<file> |
Needs no session, so anyone with a key can queue work. |
ATIMA_LIMIT_OAUTH |
30 |
/oauth/authorize, /oauth/approve
|
A person connecting an AI app. Each request makes atima fetch the app’s description from another site. |
ATIMA_LIMIT_OAUTH_APPS |
600 |
/oauth/token, /oauth/revoke,
/.well-known/
|
The AI apps themselves, signing in and renewing a token every hour. A hosted app’s requests all come from its maker’s servers, so the limit is high. |
ATIMA_LIMIT_UPLOAD |
30 | POST /api/upload |
Files sent with an upload ticket from an AI app. |
ATIMA_LIMIT_API |
1200 |
/api/ as a whole |
A ceiling. |
/mcp itself has no limit by address, because everyone
who uses a hosted AI app reaches the server from that app’s maker. atima
answers nothing there without a valid token, counts an app’s jobs
against its person’s ATIMA_JOBS_PER_USER, and lets one
connected app make ATIMA_APP_CHANGES_PER_HOUR changes an
hour.
A lecture room of people may share one address, so the defaults are
generous. If a class is turned away with status 429 when everyone opens
the page together, raise ATIMA_LIMIT_SESSION_INIT.
Behind another proxy
If your institution’s proxy or load balancer terminates TLS and passes requests to this machine, keep Caddy, on plain HTTP, for the rate limits and the header rules:
ATIMA_TRUSTED_PROXIES is the address (or network, in
CIDR form; several are separated by spaces) that the institution’s proxy
connects from. If there are two proxies in a row, for example the
institution’s and a web server on this machine, list both: every proxy
between the visitor and Caddy. Caddy then believes those proxies’
X-Forwarded-For and X-Forwarded-Proto, and
nobody else’s.
-
The visitor’s address. Most proxies add the address
they saw to the end of whatever
X-Forwarded-Forthe visitor sent, so the start of that header can be made up. Caddy therefore reads it from the right and takes the last address that is not one of the trusted proxies. A proxy that replaces the header works as well. -
HTTPS or not. The proxy nearest to Caddy must set
X-Forwarded-Protoitself on every request, overwriting what the visitor sent. - The proxies must pass the
Hostheader through, allow request bodies up to the upload limit and requests that take as long as the time limit plus the wait for a free worker, pass theAuthorizationheader and answers with status 401 through untouched (AI apps need both), and must not cache. - If other computers can reach this machine without going through the proxy, do not list their network: they are then treated as visitors, and what they send in these headers is ignored.
To see what your proxy does, send a request through it with a made-up
header (curl -H "X-Forwarded-For: 203.0.113.9" ...) to
something behind it that shows the headers it received.
loadtest/proxy-check.sh in the repository runs the whole
stack behind a stand-in proxy of this kind and checks which address a
session is stored with.
Without containers, or with another proxy
atima is an R package and the server is one function, so it can run
without Docker: install the package, set the same ATIMA_
variables, and run atima::run() under a service manager
that restarts it and stops it with an interrupt signal (SIGINT), which
is what makes it shut down cleanly. Put a reverse proxy in front that
does what the list above says. deploy/Dockerfile lists the
system libraries and the optional R packages a full server needs. Only
the Caddy configuration in this repository has been tested.
A server with auth = "none" cannot be put behind a
proxy: it refuses to listen on anything but the loopback address and
refuses requests addressed to any other host name. That is deliberate. A
server that other computers can reach needs accounts.
Usage
A shared server keeps count of how it is used. Administrators find “Usage” under “About” in the menu. The page answers two questions with numbers that can go into a grant report: how many researchers use the server, from where and for what; and is the server still big enough.
- Reach. People who completed at least one analysis (“active users”) in the last 7, 30, 90 and 365 days and ever, beside the number of accounts; active users per day, week or month; new and returning users per month; users so far.
- Repeat use. Of the people first active in a month, the share active again in each later month; and on how many days each person used the server.
- Where from. Countries, the organisations that own the networks people connect from, the institutions the sign-in provider names, and the sites and pages that link to the server.
- What for. Analyses per month by kind of diversity, each rbiom function ranked, browser against AI apps, uploads, exports and published projects per month.
- Capacity. One sentence at the top says whether the server keeps up, by a stated rule: it does not if, on more than 3 of the last 30 days, one job in twenty waited longer than 5 seconds for a worker. Below it: the median and 95th-percentile wait per day, requests refused because the queue was full (503), because one person had too many jobs (429) or stopped at the time limit (504), CPU cores in use and the longest queue per day and per hour, the time each function takes, and the disk.
- A summary for a report, for the period chosen at the top, with the definitions it rests on. Every card has a button that saves its numbers as a CSV file.
The definitions are printed on the page. A person is an account or a
guest (a browser that has not signed in); a guest who signs in is
counted once. Administrators, recognised crawlers, load tests (requests
whose user agent starts with atima-loadtest) and the health
check are left out of the counts of people and listed apart. The waiting
times cover every job, a load test’s too, since they describe the
server.
What is recorded, and what is not
For each action (opening the app, a plot, a statistic, an upload, an export and so on): the time, the number of the user’s row in the database, whether the browser or an AI app was used and the app’s name, the kind of action, the name of the rbiom function, how it ended, and how long it waited and ran. For a visit: the site and page the browser was sent from (without the query string), and the country and network owner if lookup files are set.
Not recorded: a network address, a name or email address, which project, or anything from a request other than the name of an rbiom function. No cookie is set and no other site is contacted. Requests that carry no cookie (crawlers, scripts that download by link) are counted once a day by a hash of address, user agent and a secret that is made new every day and exists only in memory; the hashes are deleted after two days.
The rows of single actions and visits are deleted after
ATIMA_USAGE_MONTHS (25). Daily counts made from them are
kept, among them one row per person per day of use, which is what
“active in the last year” is counted from. The “Privacy and terms” page
says this to the people who use the server; if you set
ATIMA_USAGE=false, nothing is recorded, the page’s
paragraph goes, and so does the Usage page.
Countries and networks
atima looks an address up in files on the server and nowhere else.
The files are not part of atima. Any database in MaxMind DB format
(.mmdb) that names a country or a network owner works; the
free ones differ in their licences:
- DB-IP Lite: “IP to Country Lite” and “IP to ASN Lite”, updated monthly, no account needed, Creative Commons Attribution 4.0. The licence asks for a link to db-ip.com where the data is used; the Usage page carries one.
- IPinfo Lite: one file with both, Creative Commons Attribution-ShareAlike 4.0, needs a free account.
- MaxMind GeoLite2: needs an account, and its licence requires that old copies are deleted within 30 days of each new release.
Put the files in one directory on the host and name it and them in
.env; the directory is mounted read-only at
/srv/geo:
ATIMA_GEO_DIR=/srv/atima/geo
ATIMA_GEO_DB=/srv/geo/dbip-country-lite.mmdb;/srv/geo/dbip-asn-lite.mmdbThe server reads the files when it starts and stops with a message if one cannot be read. Replace them with newer ones now and then (addresses change hands) and restart. An address is looked up when a visit starts and is not kept with the result. Without the files the page still works; it has no countries and networks.
What the page cannot tell you
People who run atima on their own computer are invisible by design: a local install records nothing and reports nothing. For a fuller picture, set the page’s numbers beside the ones that come from elsewhere: papers that cite atima and rbiom (a citation index), downloads of the packages (CRAN’s or r-universe’s download counts), and stars and forks of the source repository.
Looking after the server
Logs
atima writes one line of JSON per request
("event":"request": method, route, status, milliseconds,
user id) and per error, to the container’s standard error. An error
shown to a person carries a short id; the log line with the same
id has the details. Requests are logged by route, so
project keys and what requests contain are not in the log; error details
can include values from the failed request. Other events worth
knowing:
| Event | Meaning |
|---|---|
sign_in, sign_out
|
Someone signed in or out. |
oidc_discovery_failed |
The sign-in provider could not be reached at start-up. The server runs and tries again at the first sign-in. |
job_timeout |
A job passed the time limit and was stopped. |
worker_killed, worker_lost
|
A worker process had to be ended, or died; a new one took its place. |
cleanup |
Old sessions, guests, drafts or files were deleted. |
usage_failed |
An action could not be added to the record of use, or the record could not be counted. The request itself was not affected. |
db_backup, db_migration
|
A schema upgrade (see below). |
legacy_import_failed |
A project could not be imported from an older atima. |
unhealthy |
The health check failed. |
Docker keeps container logs without limit unless told otherwise; set up log rotation for the Docker daemon.
Health
GET /api/health answers {"status":"ok"}
with status 200 when the database answers and the worker pool is
running, and 503 otherwise. It starts no session. The image’s own health
check calls it every 30 seconds, and docker compose ps
shows the result.
Stopping and restarting
Stopping interrupts the R process. atima then cancels running jobs
(people see “The server is shutting down”), stops its worker processes,
writes the database’s pending changes into sqlite.db and
exits with status 0, within a few seconds; Docker waits up to 30.
Imports from an older atima that were running end, and can be started
again.
Upgrading
When a new version needs a different database structure, the server
first saves a copy of the database as
sqlite.db.v<N>.<date>.bak in the data volume,
then upgrades the database in place; the log shows
db_backup and one db_migration line per step.
To go back to the older version, stop the server, restore the last
backup from before the upgrade (below), and start the older image. The
backup service keeps the three newest of these upgrade copies.
Backups
The backup container makes a backup every night at
ATIMA_BACKUP_HOUR (UTC, default 8). A backup is a
consistent copy of the database, made with SQLite’s backup interface
while the server runs, plus the stored data files, each of which is
copied once because they never change. Copying sqlite.db by
hand while the server runs is not a backup: the database uses a
write-ahead log, and the file alone can be incomplete.
The newest ATIMA_BACKUP_DAILY (7) backups are kept, and
the newest of each of the last ATIMA_BACKUP_WEEKLY (4)
weeks. Backups hold everything the server holds, including data that
people have since deleted, until the backup itself is removed. Protect
the backup directory as you protect the server.
docker compose run --rm backup backups # list the backups
docker compose run --rm backup backup # make one nowTo restore, stop the server first:
docker compose stop atima
docker compose run --rm --no-deps backup restore atima-20270115T080000Z.db
docker compose start atima--no-deps matters: the backup service is set to start
after atima, so without it this command starts the server you have just
stopped, and restore then refuses because the database is
open.
The database that was there is kept beside the restored one as
sqlite.db.before-restore.<date>; delete it when you
are sure. If the server was not shut down cleanly, restore
refuses, because it cannot tell a crashed server from a running one; add
the word force after the backup’s name once you are sure
the server is stopped.
Test a restore on another machine before you rely on the backups.
Importing from an older atima
Importing from an older atima
explains how to make the file that holds an old installation’s data. To
give it to the container, set in .env
and add the second compose file to every command:
The file is mounted read-only. It is as sensitive as the old
database: keep it readable only by user id 10001
(chown 10001, chmod 400). An import can keep a
worker busy for up to 15 minutes per project, so give the server at
least three cores (two workers) while people are importing.
How large a server
Memory: each worker is an R process with rbiom loaded. On the development machine a worker held 500 to 650 MB after drawing plots of the larger example project (1,006 samples), and the main process 400 MB. atima starts no more workers than one for every 2 GB of the container’s memory; datasets near the upload limit will need more.
CPU: ATIMA_CPUS is the number of cores the server may
use, and defaults to all the container has (atima reads a CPU limit you
set with Docker). One core is kept for the process that answers
requests, and there is a worker for each of the others, so a server with
8 cores runs up to 7 jobs at the same time. A job that calls an rbiom
function with a cpus argument (most plots, statistics and
tables) is told it may use up to half of the cores that are free when it
starts, or its share of them if other jobs are waiting; every other job
has one core. Those cores are reserved for the job until it ends, and
only then are they free for other jobs. A job never waits for more than
one core.
atima counts the cores it has handed out; it does not measure what a
job uses. R in the container uses OpenBLAS for linear algebra, which
starts a thread for every core, whatever a job was told it may use, and
those threads make the ordinations slower, not faster. Unless your rbiom
limits them itself, start the server with
OPENBLAS_NUM_THREADS=1 in its environment, or it can use
more than ATIMA_CPUS cores.
What happens when the server is too small: requests that need a worker wait in a queue of ten per worker. A plot that would take one second takes longer because it waits; when the queue is full, new requests are answered 503 (“The server is busy”) until there is room. Requests that need no worker (loading the page, the project list, signing in) are answered by the main process and stay fast.
The repository has a load test (loadtest/) that
simulates people browsing, one account starting many jobs at once, many
people signing in together through a slow provider, and AI apps calling
tools. On the development machine (a six-core desktop from 2018,
everything in containers on that one machine, so five workers):
- Loading the page took 0.6 seconds or less for 19 of 20 visitors in every run, including runs in which jobs waited most of a minute.
- Most plots ran for one or two seconds. A permutation test (PERMANOVA, 999 permutations) on a project of 1,006 samples ran for 30 to 46 seconds, on one core, and holds its worker for that long. Jobs like that decide how many cores a server needs.
- Ten people who each did something every 5 seconds were served without waiting: half of their jobs started at once, 19 in 20 within 5 seconds.
- Thirty such people were more than this machine could serve promptly: half of their jobs waited 11 seconds or more. Nobody was turned away. With OpenBLAS left at its defaults, ten of the long permutation tests were stopped at the time limit; with one thread, none was.
- Ten sign-ins at once through a provider that took two seconds to answer did not slow the server for anyone else.
loadtest/README.md in the repository has the method and
the full tables, and says how to run the test against your own server
before you open it. If people will bring projects of more than a
thousand samples, consider a longer time limit
(ATIMA_TIME_LIMIT): on this hardware the largest jobs came
within 14 seconds of the default limit of 60 when the server was quiet,
and passed it when five of them ran at once.
What is not protected
- Anyone who has a project’s link (its private key) can open the project and download its data. That is how sharing by link works; “New link” on the Sharing page replaces the key.
- Links to figures and exports work for anyone who has them, for a day.
- Whoever administers the machine can read everything on it. The data is not encrypted at rest.
- Public projects are published by their editors without review.