limit order matching engine
concurrent price-time priority order book exposed over REST and live WebSocket streaming.
java, spring boot, postgresql, docker, websocket (stomp), gatling
Matches incoming orders by price then arrival time against a TreeMap<BigDecimal, Deque<Order>> book, resting unfilled quantity and stamping each trade with a monotonic sequence number under a ReentrantReadWriteLock so match order stays recoverable even if broadcasts arrive out of order. Trades persist to Dockerized PostgreSQL and stream live to clients over STOMP alongside full book-depth snapshots.
Load-tested with Gatling from 200 to 2,000 concurrent users: throughput scaled 5x, from 333 to 1,667 req/s, with zero failures across 110,000 requests. Profiling showed sustained 80-90% CPU during the heavy run, pointing to a CPU-bound ceiling rather than lock or I/O contention.