Re:Preventing server overload: limit requests being processed
by thunderbong on Monday August 07, 2017 @10:27PM
(#14953294)
That's really interesting. Can you tell more about how it is implemented technology wise?
[ Parent
| on HN ]
Re:Preventing server overload: limit requests being processed
by Animats on Monday August 07, 2017 @10:38PM
(#14953407)
Python and MySQL/MariaDB. The queue is an in-memory table. Fair queuing is implemented as a big SQL SELECT statement.
The time scale is slow enough that polling it once a second for new work is sufficient. If it had to go fast, it would require something like a standard fair queuing implementation, where you hash the IP address and put the request onto 1 of N queues, serviced round-robin.
Re:Preventing server overload: limit requests being processed
by javajosh on Monday August 07, 2017 @10:46PM
(#14953484)
Doesn't matter all that much. For ingestion, you might have one VM running one Java process and one DB process as a microservice (I like Dropwizard and PostgreSQL for this). The worker itself would be another Java process with a 100 thread max thread pool that either periodically checks for new work, or uses the new NOTIFY semantics new to Postgres 9.6. In this case the "secret sauce" is that the worker has some extra smarts to reorder the queue to avoid resource hogs, which is the cool part.