-2

Our android application is built on java. And while sending push notifications we're using tomcat as a server. And it is doing more harm than good. Currently all the push notifications (FCM/APN) are pushed all at once. As I said they're not real time notifications that need to be delivered all at once. They can be delivered within 1 week intervals and nobody will complain, whereas sometimes they need to be delivered on real time basis(for example on festivals or offers that last only for few days).

What's the best way to deal with this?

2 Answers 2

1

best way to deal with this?

Introduce a pair of priority levels. Push the "urgent" notices. And all others can be polled for by an hourly (or midnight) batch job.

It sounds like even your urgent ones may suffer from unfortunate queue depth. Add random jitter to the due dates, so that only some reasonable number of requests will arrive in any given minute.

Alternatively, put a dollar figure on what timely delivery means, in expectation, for a given message. Use that in a sql select ORDER BY clause, so you're paying attention to ones that matter before handling the notifications that could as easily go out tomorrow or next week.

1

Consider implementing a queueing system (database queues, Kafka, RabbitMQ,...) with two queues, real-time and not real-time. Persistent queues will guarantee no lost messages while letting you control how quickly you process.

You can then adjust the number of consumers on each queue to balance meeting delivery requirements and limiting load on the server. You could even make this more dynamic by throttling/releasing as load on the server changes.

2
  • Queues are already implemented.
    – tuck_y
    Commented Dec 3, 2023 at 8:49
  • If you have a separate queue for the delayed messages and you can fully control how much processing you do there, what is actually putting the large load on the server?
    – cdkMoose
    Commented Dec 4, 2023 at 14:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.