March 24, 2022
Synchronous vs asynchronous processes
- Batch processing
- Stream processing
- Lambda architecture
- Asynchronous queues
Batch processing - most popular implementation - MapReduce
Stream processing - data flows into your system as events occur. Events may be changes in state, or updates.
Asynchronous queues
- Message queues
- Task queues
- Publish/Subscribe (or pub/sub)
When to bring it up in an interview
Consider async processing for applications with:
- Long expected processing times, or when the processing time is unclear.
- No need for immediate processing. A classic example is Facebook's newsfeed. A newly uploaded post will be immediately visible in your own feed but it may take some time before it's visible to your entire network.
Batch processing is useful when you need to process chunks of data in predictable intervals, as in accounting software. Stream processing is a good choice for applications like anomaly detection or sentiment analysis when timeliness is critical, and lambda architecture can help you capture the benefits of both if you're willing to deal with added complexity. Synchronous processing is still the best choice for simple applications where processing times are short and well-defined, and when errors must be dealt with immediately like in payment tools.
Take a look at the below table to help guide your decisions when prepping for your interview:
Applications
- Analytics
- Web crawling
- Handling large file uploads
- Handling real-time events
- Generating a newsfeed
- Scheduled tasks
- Analytics - Batch processing, MapReduce
- Web crawling - Batch processing, MapReduce
- Handling large file uploads - Job queue
- Handling real-time events - Stream processing
- Generating a newsfeed - Job queue, Pub/Sub
- Scheduled tasks - Job queue, Batch processing
No comments:
Post a Comment