5 ms·
I don't build web servers so perhaps I'm going off topic, but I have found it useful to sometimes combine both models - which may not be all that surprising bec
by ryanjshaw 13y ago
I don't build web servers so perhaps I'm going off topic, but I have found it useful to sometimes combine both models - which may not be all that surprising because both models developed to satisfy different requirements, which can crop up in a single problem at the same time.
A concrete example: I'm experimenting with a small analytics service where one part of the implementation is that I need to scrape about ~10 million forum posts across ~500k web pages.
A purely event-driven approach makes scraping very easy but throttling requests, handling errors and retries quickly becomes messy and difficult to reason about. A purely thread-driven approach makes throttling much simpler but scraping harder.
I found that implementing scraping with events (i.e. push a URL to a queue + specify a callback type + state) and downloading with threads (i.e. process the queue(s) with a request throttling window) much more manageable with some nice side benefits (e.g. persistent queues are easy to implement).
I haven't looked at goroutines, Rust tasks or Dart Isolates -- are you suggesting that one model can be sufficient for general purpose computing?