r/cloudcomputing • u/ThatsFudge • Jun 21 '23
Adapting a (badly designed) microservices solution to cloud, efficiently
Hey everyone
I am working on a SaaS project that includes around 8 microservices, written in python.
Since I have no strong background in software, let alone cloud architecture, I built it so each microservice is a docker container with a REST API server that stays up always, waiting for requests.
Most of the microservices are webscrapers, using Playwright (same as Selenium for that matter)
To save on overhead of [opening a browser, navigating to the page, scraping, ] each time a request comes in, I leave the browser open and with an internal message queue the Playwright worker does whatever, based on the parameters.
Now, I looked towards deploying it to the cloud and I have realized that leaving a browser open while idle will be very costly.
I am looking for guidance since I am not very familiar with the topic. Also, since I am only at MVP stage, I would want a solution that is the most easily implemented, without reconstructing my design from zero, if possible, and of course, financially efficient.
Also, I wonder what are the best practices and what should I do next time I am faced with such project.
Thank you for reading
View all comments
Show parent comment
1
u/ThatsFudge Jun 21 '23
Hey, thank you for your reply. I am running in headless mode. The overhead is loading the page, logging in, before doing the scraping job.
With my implementation, the browser opens, logs into the website immediately on boot, and waits for commands. And on each request, it goes to a section of the website and scrapes.
I realised that the browser hanging around will cost me extra cpu time.
So, the best and only option is to have dockers that go up, handles a request, and go back down?