Spining up 2 different containers for the same codebase if you have to expose API as well as run cron you will endup scaling the containers even though those are in the cloud and autoscale group.
Problem - Team X is developing a microservice which is basically performing some CRUD operations in the RDS,take an example of that article publisher with the scheduler for publishing and unpublishing at a specific time, Now the schedule runs every minute and with single container it brings down the container if the hit comes for CRUD operation. You can put the container in the autoscale group the experience is still the performance, Some time some APIs take more time to respond. In this case, there have to be more and more containers and each container is performing the dual-task. That's the glitch in the architecture.
Solution - Make each container for a single task, which means if the container is servicing APIs it should not perform the cron job at all or vice-versa. How to implement - You can have the same codebase but during the deployment in your CI/CD cycle, just create two different containers with different names for API and CRON job respectively. E.g publishing_api and publishing_cron etc. with environment variable you can switch-in or off the container.
Questions for the readers-
What do you think if there can be more options to achieve such objectives?
Does it impact on the RDS or the DB on on-premises?