This demonstrates a very simple Go HTTP server that can:
- process 200k TPS at ~300microseconds latency
- with each message being persisted to disk before being processed
- all transactions processed serially and therefore atomically
The chess example shows 70k TPS at sub-millisecond latency.
This is equivelant to about 5b chess games a month.
Chess.com has around 1b games per month.
So this is the kind of scale you can get if you keep the hot-path fast and move the slow stuff out to other services.
go run .
wrk http://127.0.0.1:8080/ --latency -t8 -c64 -d60sThe "framework" code (i.e. the code that writes to disk and orders all messages) is in wal/wal.go
The other files are:
main.go- starts up the WAL and the http servercounter_state.go- the processing of messages to update statecounter_routes.go- the http endpoints
Similarly the state and routes files are available for the chess server as well.
By bringing all messages back to a single thread, they can be totally ordered and persisted to disk in batches. Then they are sent in this order to the message handlers that update state (also on a single thread).
Inspired by the LMAX Architecture