System Design Concepts — 1

Synchronous vs. Asynchronous API Calls

Understanding Blocking and Non-Blocking Operations

BaseCS101
Javarevisited
Published in
5 min readSep 15, 2023

--

Sync vs Async

When designing high-performance applications, understanding the difference between synchronous (sync) and asynchronous (async) APIs is crucial. These two concepts determine how an application handles requests and responses, influencing performance, responsiveness, and user experience. In this article, we will explore the key differences between sync and async API calls, delve into callbacks, and see detailed examples to clarify these concepts.

What is Synchronous API (Blocking)?

A synchronous API blocks the execution of code until a response is received from the server or another system. When you make a synchronous call, the program pauses and waits for the API to return a result before proceeding. This behavior can lead to delays, as your application will be idle while waiting for the external process to complete. However, synchronous calls ensure that operations are performed in sequence.

Now Let’s see a Detailed Example:

Imagine you’re calling an API to fetch user details from a server.

def get_user_details_sync(user_id):
response =…

--

--

BaseCS101
Javarevisited

-: Empowering Developers to Ace Their Technical Interviews :-