Skip to content

Instantly share code, notes, and snippets.

@pglombardo
Last active August 29, 2015 14:03
Show Gist options
  • Save pglombardo/2029bdd0ac053d57a41a to your computer and use it in GitHub Desktop.
Save pglombardo/2029bdd0ac053d57a41a to your computer and use it in GitHub Desktop.
TraceView Async Event Logging

HOW-TO: ASYNCHRONOUS AND PARALLEL WORKFLOWS

Most web application requests follow a simple path through the application, regardless of whether it is blocking or evented, where the critical path of the request is the only work being done. However, some web applications make use of threads, eventlets, or queues to process work in parallel or out of the critical path.

In order to analyze traces with asynchronous and parallel workflows correctly, small annotations must be added to the trace’s events. They boil down to adding the key Async = True on “asynchronous” layers. Here’s how to handle two common scenarios:

FIRE AND FORGET

Your application might want to do some work from which the return value is not necessry. Why put it in the critical path? So you spin off this work to a second thread. The asynchronous thread, or the work within it, should be given its own layer with the Async flag:

[ rawview annotated ]

PARALLEL REQUESTS

You’re querying 10 sites at once, or maybe 10 databases, and you need the replies from all of them--the app will be blocking anyway, so why do this work serially? Each separate query or RPC, or a layer containing it, should get the Async flag:

[ rawview annotated ]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment