Self-hosting Typesense on bare metal

Typesense returns typo-tolerant results in milliseconds because it keeps its index in memory. A dedicated machine gives it plenty of memory at a predictable monthly price.

What does Typesense do well?

Instant search for product catalogues, documentation, directories and apps. It is an open-source engine written in C++ with typo tolerance, faceting, filtering, sorting, synonyms, curation and geo search built in, plus vector and hybrid search for semantic matching. Its API is simple JSON over HTTP, and results for typical queries come back in a few milliseconds.

How do I install it?

From the project's packages for Debian and Ubuntu, or its RPMs for the EL family. The service reads /etc/typesense/typesense-server.ini.

curl -O https://dl.typesense.org/releases/VERSION/typesense-server-VERSION-amd64.deb
apt install ./typesense-server-VERSION-amd64.deb
systemctl status typesense-server
; /etc/typesense/typesense-server.ini
[server]
api-address = 127.0.0.1
api-port = 8108
data-dir = /var/lib/typesense
api-key = REPLACE_WITH_A_LONG_RANDOM_KEY
log-dir = /var/log/typesense

Replace VERSION with the current release from the project's download page.

How do I create a collection and add documents?

Define the schema, then import JSON lines. Fields you search or filter on are indexed in memory; other fields are stored on disk only.

curl -s http://127.0.0.1:8108/collections -H "X-TYPESENSE-API-KEY: $TS_ADMIN" -d '{
  "name": "parts",
  "fields": [
    {"name": "title", "type": "string"},
    {"name": "brand", "type": "string", "facet": true},
    {"name": "price", "type": "float"},
    {"name": "stock", "type": "int32"}
  ],
  "default_sorting_field": "stock"
}'
curl -s "http://127.0.0.1:8108/collections/parts/documents/import?action=upsert" -H "X-TYPESENSE-API-KEY: $TS_ADMIN" --data-binary @parts.jsonl

How do I expose search safely to browsers?

With a search-only key, never the admin key. Create a key limited to the documents:search action on specific collections, and for per-user restrictions generate scoped keys that embed filters, so a customer can only ever see their own records. Put nginx with a certificate in front of port 8108, or bind Typesense to a public address with its own TLS settings, and rate-limit the search path.

How big should memory be for my index?

Plan for two to three times the size of the fields you index, plus headroom. A catalogue of 5 million products with 1 KB of searchable text each needs around 10 to 15 GB of memory. Vector fields add the size of the vectors themselves: 5 million 384-dimension float vectors take about 7.7 GB before index overhead.

IndexMemoryMachine
Up to 2 million documents, text onlyUnder 16 GBESSENTIAL-1
10 million documents with facets20 to 40 GBESSENTIAL-4
Text plus embeddings for semantic search60 to 110 GBESSENTIAL-5

ESSENTIAL-5 brings 128 GB DDR4 and 24 cores at $120.00 a month. Built-in embedding models run on the CPU during import, and many cores shorten that step considerably.

How does clustering work?

Typesense replicates with the Raft protocol across three or five nodes, which tolerates the loss of one or two. Each node lists its peers in a nodes file in the form address:peering_port:api_port, using peering port 8107 by default. Since we do not offer a private network between servers, connect nodes over WireGuard and use the tunnel addresses in the nodes file.

echo "10.9.0.1:8107:8108,10.9.0.2:8107:8108,10.9.0.3:8107:8108" > /etc/typesense/nodes
# then in typesense-server.ini: nodes = /etc/typesense/nodes and peering-address = 10.9.0.1

Clients send writes to any node; they are forwarded to the leader.

How do I back it up?

Use the snapshot endpoint, which writes a consistent copy of the data directory to a path you choose, then archive that path to another machine.

curl -s -X POST "http://127.0.0.1:8108/operations/snapshot?snapshot_path=/var/backups/ts-snap" -H "X-TYPESENSE-API-KEY: $TS_ADMIN"

Rebuilding from the source of truth is also a valid plan for many catalogues, so keep the import scripts in version control. The Database servers page covers the database that usually feeds the index.

Machines for Typesense search

Lowest monthly price of each model across its data centres; the model page shows the price in every location.

ModelProcessorCoresMemoryDrivesPortPer month
ESSENTIAL-1Intel Xeon-E 2386G632 GB2x 512 GB SSD NVMe1 Gbps unmetered$38.40
ESSENTIAL-SAMD Ryzen 7 9700X864 GB2x 512 GB SSD NVMe1 Gbps unmetered$46.20
ESSENTIAL-4AMD EPYC 73131664 GB2x 960 GB SSD NVMe1 Gbps unmetered$106.20
ESSENTIAL-5AMD EPYC 741324128 GB2x 960 GB SSD NVMe1 Gbps unmetered$120.00
BUSINESS-2 2024AMD EPYC 4344P864 GB2x 960 GB SSD NVMe3 Gbps unmetered$109.80
BUSINESS-5 2024AMD EPYC 8224P2496 GB2x 960 GB SSD NVMe3 Gbps unmetered$280.20

Size memory for the indexed fields plus vectors, then pick a model with headroom.

See all servers and prices

Related pages

Database servers

NVMe machines with large memory for PostgreSQL, MySQL, MariaDB and MongoDB, from a single primary to replicated pairs.

Read more

E-commerce shops

Single machines and two node setups for WooCommerce, Magento, PrestaShop and headless shops that must stay fast at checkout.

Read more

Valkey servers

Run Valkey, the open-source in-memory data store, on bare metal: I/O threads across cores, clusters, persistence, moving over from Redis and sizing.

Read more

ECC memory explained

Why servers use error correcting memory, how full ECC differs from DDR5 on-die ECC, and which of our machines carry which.

Read more

Questions and answers

Does Typesense keep the whole index in memory?

Yes, the fields you search, filter or sort on are held in memory for speed; other stored fields stay on disk.

Which port does Typesense use?

Port 8108 for the API by default, and 8107 for peering between cluster nodes.

How do I estimate RAM for a Typesense index?

Roughly two to three times the size of the indexed fields, plus the size of any vectors, plus headroom for growth.

How do I let a website search Typesense securely?

Create a search-only API key limited to specific collections, or scoped keys with embedded filters, and never expose the admin key.

How many nodes does a Typesense cluster need?

Three or five. Raft replication keeps the cluster available if one node, or two in a five-node cluster, goes offline.