I would suggest establish monitoring to understand why your microservice is restarting, though if it is being restarted it is more likely related to memory than CPU. We have an article describing best practices around monitoring:
which links to two articles that show how to do monitoring for Python and Java microservices.