My current task is to set up a system that pushes out notifications to specific users based on a set schedule. Having tackled the push notifications issue, I am now trying to put together a system that will actually send out those push notifications on a regular basis. Since our infrastructure is based on a Kubernetes cluster populated with ephemeral containers, a VM with cron isn't possible, so I've come down to two possible solutions:
- Write a process that sits in a Docker container and on a regular schedule using cron, run the task to determine what notifications to send and then send them out
- Write up a small process that determines what notifications need to be sent at the current point in time and schedule that as a recurring Kubernetes cron job
The first seems to be a relatively straightforward implementation that would be implemented the same way in a VM and in a Docker container, but my concern is that, in an environment where pods are expected to not last for very long, some events may be lost. The Kubernetes solution, from that standpoint, seems more robust since the scheduling occurs at a higher level than the actual container. The triggered script itself would also be simpler as it would be a one-off process that ends and then kills the container off until the next scheduled runtime.
Right now I'm leaning towards the second solution, but if anyone has some experience with putting this kind of thing in to practice it would be great to hear some other perspectives on how to implement this kind of server.