Airtime top-ups: should you go sync or async?

Mauro Chojrin

Mauro Chojrin

2 min

When developing an application that relies on Reloadly’s top-up API sooner or later you’ll have to make a decision: sync or async.

While both options help in achieving the end goal of providing credit to a recipient mobile phone, the way the operation is performed is different so you need to understand their differences in order to make an informed decision that matches your specific requirements.

Let’s start exploring those differences.

What is the difference between a synchronous and an asynchronous top-up

There are two main difference between a synchronous and an asynchronous operation:

  1. When you receive an answer from the server
  2. How do you know when your operation has been carried out

In the case of the synchronous call you won’t get an answer until the operation has finished, regardless of the result being success or failure.

In the asyuncrhonous call you’ll get an immediate response from the server informing you that the operation has started, but that doesn’t give you any information as to the result of it.

In order to get status updates you must do a polling cycle or implement a webhook.

When should you prefer a synchronous top-up

If your application can’t do anything until the top-up operation has finished you’ll probably prefer to use a synchronous call.

These usually work well in environments where the concurrency is low.

Check out the documentation to get a better idea on how to use synchronous calls.

When should you prefer an asynchronous top-up

If you’re in a high concurrency environment you’ll probably want to maximize parallelism so users don’t suffer from bottlenecks.

In these scenarios, although a little harder to implement, asynchronous operations are preferrable.

Read here to get information about how to issue asynchronous calls and here for how to check the status of previously issued calls.

Conclusion

In this post you learned the difference between synchronous and asynchronous topups, their pros and cons and a criteria to choose between them.

Now it’s your turn to select the best fit for your needs and implement it in your application and, as always, if you need further help you can reach out to us via the usual channels.

This might also interest you:

3 min
Micro-rewarding is transforming how businesses, educators, and organizations engage with their audiences. By offering small, frequent incentives, this innovative approach enhances loyalty, drives behavior change, and keeps people motivated. Learn how micro-rewarding can create big impacts with minimal costs.

Content by developers to developers.

Subscribe to The Monthly Reload for Developers and start receiving all the developers’ updates.

The Monthly Reload: the newsletter for you

Subscribe to our Newsletter and don’t miss any news about our industry and products.

It’s time to build, make your first API call today