Under the hood

Nasjonalmuseets API is hosted on a Ubuntu 20.04 server with 5.4.0-37-generic kernel.

We’re using FastAPI, a very fast web framework for building API with Python 3.6+.

The data is stored in a MongoDB database as JSON objects.

Images is stored on in different resolutions for fast access; fullsized JPGs, Pyramidical TIFFs and Thumbnails (180×180) for use in for example Tensorflows datasets.

Requests to MongoDB is done with Motor, a asynchrounous Python driver for non-blocking access to MongoDB.

Deployment is done with Docker. This allows us to quickly put new versions into productions.

Docker is running in Swarm-mode for scaling beyond single servers and for easily managing containers over multiple hosts.

We’re using Traefik as HTTP as load balancer/proxy that automatically load balances the containers. Traefik also handles our SSL certificates via Letsencrypt

HTTP requests is handled by a uvicorn-gunicorn ASGI server, with “auto-tuning” mechanism based on the amount of available CPU cores on our server(s).