Blocking Operations, Exceptions, and Logging in Asynchronous Servers
Source: YAPC::NA 2014 on the 2014-06-24.
Speaker: Doug Hoyte (fractal)
This talk is about lessons learned while designing, building, and operating asynchronous servers. Instead of focusing on the concepts of async programming and the benefits it provides in terms of performance and determinism, we'll discuss the problems that inevitably come up.
Although not the only solutions to these problems, this talk describes three modules that your users, other developers, and operations team will appreciate:
AnyEvent::Task -- Doing any sort of blocking operation in an async server will ruin your performance. AnyEvent::Task is a pre-forked worker-pool implementation that lets your async program safely and efficiently perform any sort of blocking operation, including CPU-bound tasks.
Callback::Frame -- Exception handling is notoriously difficult in async servers. Callback::Frame unifies the various error-handling techniques used by different async libraries and even lets you do the right thing when exceptions are thrown in AnyEvent::Task worker processes.
Log::Defer -- Because in async servers you can't use process or thread IDs to follow a connection's progress, log files are often jumbled and confusing. Log::Defer implements an async-friendly style of logging known as structured logging that also supports timing data collection, flexible queries, and the log-defer-viz visualisation tool.