How many instances of web server are you going to have? Is it going to sustain the 10000 requests in a second?
If one server instance is fine, then a single GenServer per course sounds like a good solution. Looks like your constraint is just a counter (30 seats). Assuming you have a reasonable DB (INSERT is just a few milliseconds), you can just write the record immediately and have all the consistency guarantees. So the GenServer would be something like:
- Start the GenServer with course id,
- On
init(orhandle_continue) get the booked seats, - On each “book a seat” message, check the counter, write to DB if seat available, return result.
Be sure to bump the timeout on the GenServer.call when sending the “book a seat” message. I think this should be good enough, but it’s hard to tell without real performance tests.
If it turns out that you need multiple instances of the web server, then things get a bit more hairy. You could go with Erlang distribution or use out-of-process cache like Redis.


















