Thursday, March 24, 2022

Exponent: Day 2 to be a student | Fundamentals of system design

 March 24, 2022

Synchronous vs asynchronous processes

  1. Batch processing 
  2. Stream processing
  3. Lambda architecture
  4. 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

  1. Message queues
  2. Task queues
  3. Publish/Subscribe (or pub/sub)
Publish/Subscribe (or pub/sub) messaging is another async communication method to know. In pub/sub messaging, you have a subscriber who receives a message sent by a publisher via a broker. Because communication is decoupled, messages can be automatically pushed to all subscribers rather than pulled individually via a message queue. This method is popular in event-driven architecture because event-driven service can be delivered quickly and easily. Additionally, because publishers are isolated from subscribers, the system is easier to maintain and secure. 

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
Processing Methods to consider
  • 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