Opinary is a platform that allows readers to express their opinion on articles through interactive polls. One of the main goals of Opinary is to increase reader engagement and make the reading experience more interactive. In this blog post, we will discuss how we were able to achieve this goal faster by migrating our recommendation system to Google Cloud Run.
Architecture of our recommendation system:
Our recommendation system is based on a microservices architecture, where different services are responsible for different tasks such as collecting data, processing data, and serving recommendations. These services communicate with each other using HTTP requests and responses.
Why we decided to move to Cloud Run:
We decided to move to Cloud Run for several reasons. First, Cloud Run allows us to deploy our services as containers, which makes it easy to scale and manage them. Additionally, Cloud Run automatically scales our services based on traffic, which means that we don’t have to worry about provisioning enough resources to handle high traffic.
Enabling the migration to Cloud Run with a few changes:
The migration to Cloud Run was relatively straightforward. We had to make a few changes to our services to make them compatible with Cloud Run. For example, we had to update our services to use the Cloud Run-provided environment variables instead of hard-coded values. Additionally, we had to update our services to use Cloud Run’s built-in logging and monitoring features.
Changing Pub/Sub subscriptions from pull to push:
One of the key changes we made was changing our Pub/Sub subscriptions from pull to push. This allowed us to receive messages from Pub/Sub as soon as they are published, rather than having to periodically poll for new messages. This made our recommendation system much more responsive and reduced the latency of our services.
Introducing a Cloud Memory store Redis instance:
Another change we made was introducing a Cloud Memorystore Redis instance. This allowed us to cache frequently accessed data in memory, which reduced the number of requests to our services and made our recommendation system faster.
Making it faster using Cloud Trace:
We also used Cloud Trace to analyze the performance of our services. This allowed us to identify bottlenecks and optimize our services for better performance.
Waiting for responses is expensive:
One thing we learned during the migration was that waiting for responses from our services is expensive. To mitigate this, we introduced a load balancer that routes requests to the least loaded service. This reduced the response time of our services and made our recommendation system faster.
Rethinking the architecture:
The migration to Cloud Run forced us to rethink our architecture. We had to make several changes to our services to make them compatible with Cloud Run, and this made us realize that we could make our recommendation system faster and more scalable by making other changes.
Advice and conclusion:
If you’re thinking of migrating to Cloud Run, we recommend that you take the time to analyze your current architecture and identify opportunities for optimization. Additionally, we recommend that you think about how you can take advantage of the built-in features of Cloud Run, such as automatic scaling and built-in logging and monitoring. By following these tips, you’ll be able to make your application faster and more scalable, just like we did with Opinary.
In conclusion, migrating to Google Cloud Run has allowed us to significantly increase the speed and scalability of our recommendation system at Opinary. By using Cloud Run’s built-in features such as automatic scaling, built-in logging and monitoring, and by taking advantage of other Google Cloud services like Cloud Memorystore Redis and Cloud Trace, we were able to optimize our architecture and reduce latency. We also learned that waiting for responses from services is expensive, so we introduced a load balancer to route requests to the least loaded service.
By following these best practices, we were able to increase reader engagement and make the reading experience more interactive. This migration is an example of how moving to Cloud Run can be beneficial for businesses that are looking to improve their application’s performance and scalability.
Leave a Reply