Best Strategy for Sending Messages

Hey Ppl!

in my app i provide a Chat where Chat messages can be send via LinkedIn API.

and the “Send” Button will be used a lot of times. Whats the best practice for this case?

Should i build a queue where i collect all the Button Clicks and Trigger a send Message Workflow one at a time or is there a “Standard Way” how to handle this?

There isn’t a standard way per se. It depends on your use-case at the end of the day. If you wish to send the message to the chat immediately, no need for a queue system. Just call the API immediately.

In case, the API allows for bulk message creation, and the users are okay with a latency, you can use the queue and run the API once to create those messages.
However, if there’s no bulk action in the API, it doesn’t make sense for a queue-like implementation, unless, your use-case needs it.

Let me know if this makes sense.

If you think that this will slow down your system because it will be used so often and by many users at the same time, I would recommend the queue system if it doesn’t need to be sending data live. That way you won’t overload your system and it can slowly go through the queue when it gets to it. It does help when scaling your app if you know that this will be being pressed very often. I think it’s a good idea. :blush: It isn’t super hard to set up and I think worth the peace of mind it provides.

Just another point of view. :blush:

Hey @tbaohoang94

APIs can handle a vast number or requests. Based on my experience the only thing you will need to watch out for is the rate limit for the particular API you are working with.

I typically have a recursive retry that reschedules an API call only if it fails or in the event that its being rate limited.

You can do this in different ways in bubble, but the simplest strategy is to create a backend workflow that you schedule to send the message immediately. If the reply is an error then schedule the same workflow to try again after a few seconds.

Now that being said, you ideally should have a way to store the number of attempts before the app flags this as an error. For example if the API call fails then increment a field by +1, then retry till the number of attempts is >= 5 (example)

Be sure to be careful when working with recursive workflows :blush:

This topic was automatically closed after 70 days. New replies are no longer allowed.