API Maker

The framework for AI era

Performance

Low Memory Footprint

Built to run well on small servers: 1 CPU core and 1 GB of RAM is enough to start.

API Maker loads only the database drivers you use, serves every table with the same handlers, streams big results in small pieces, and keeps its queues bounded. Your own code runs in sandbox containers, so a leak there does not grow the API Maker process.

See it live

Step through it, slow it down, or open the full canvas.

api-maker/features/low-memory-footprintLive
  • Loaded
  • Not loaded
  • Data
  • Crash
RAM
1GB · 1 vCPU
Drivers
1loaded
In memory
2bunches at most
Req/s
788benchmark avg

Only the drivers you use are loaded. A database driver is loaded the first time an instance of that database is used. Connect only MySQL and PostgreSQL, SQL Server and Oracle drivers never load.

How it works

  1. Only the drivers you use are loaded.

    A database driver is loaded the first time an instance of that database is used. Connect only MySQL and PostgreSQL, SQL Server and Oracle drivers never load.

  2. Five thousand tables, the same handlers.

    Generated APIs are generic routes. A new table adds no code to load: the same handlers serve orders, customers and every other table.

  3. Millions of rows, a few in memory.

    Stream APIs read 1000 rows at a time and write them in 64 KB pieces, waiting when the client is slow. At most two bunches are in memory, whatever the size.

  4. Leaky code can not fill the server.

    Your code runs in sandbox containers. Set a restart interval and each one is replaced on time, the requests inside finish first.

  5. A crash is not an outage.

    When a worker process dies, the cluster starts a new one. systemd keeps the main process running.

  6. A $5 server, 788 requests per second.

    Linode 1 GB RAM, 1 vCPU, MongoDB and Redis on the same server: the get all API averaged 788.89 requests per second, 47k in 60 seconds.

What you get

Drivers on demand

The driver of a database type is loaded the first time an instance of that type is used. The others never load.

No code per table

Generated APIs are generic routes: five tables or five thousand, the same handlers serve them.

Streams with backpressure

Stream APIs read 1000 rows at a time and write them in pieces of about 64 KB, waiting for slow clients. A request holds at most two bunches.

Bounded queues

API logs are written in batches of up to 1000, and at most 10,000 wait in memory. Responses over 1,000,000 characters are not cached.

User code outside

Custom code runs in sandbox containers with their own heap limit, and they can be restarted on a timer.

Workers sized to the server

Set cpuCount, or AUTO for one worker per 2 GB of RAM, up to the number of cores. A worker that dies is started again.

An example

API Maker, MongoDB and Redis on a $5 server

In the benchmark of the docs (April 2023), a $5 Linode with 1 vCPU and 1 GB of RAM ran API Maker, MongoDB 6 and Redis together. The schema get all API averaged 788.89 requests per second over 60 seconds, 47k requests in all.

Good to know

  • Memory use depends on your traffic, your data and your code: measure with your own load. The benchmark ran API Maker, MongoDB and Redis on the same 1 GB server.
  • Sandbox containers use memory of their own, next to the API Maker process.

Questions

How many workers does API Maker start?

As many as cpuCount says. With AUTO it takes the smaller of the CPU count and the RAM in GB divided by two, and at least one.

Where are the benchmarks?

In the docs, with the server, the API and the numbers of every run, from 1 to 8 CPUs.