0

In my eCommerce microservices app, I want to create a page to display the order summary. The order contains a group of products, each with its own ID. Should the front end make multiple requests to fetch the details of each product? Is there a design pattern or best practice to improve performance, such as making rest requests in parallel, service aggregator, BFF, or asynchronous communication?

I'm new to microservices, but I've come across these terms and would like to understand the best approach.

2
  • Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. Commented Oct 5, 2024 at 4:41
  • "Should the front end make multiple requests to fetch the details of each product? " - why? why can't it make a single request fetching all needed data? Commented Oct 5, 2024 at 6:53

1 Answer 1

0

Understanding that read operations are typically more resource-intensive than write operations is crucial. This disparity depends, of course, on the complexity of your solution. From a front-end perspective, read operations to display data are the most common and also the most demanding on your backend, especially if you're aiming to maintain Service Level Agreements (SLAs) under 500 milliseconds—a standard benchmark for acceptable response times. To achieve this, you might need to scale your microservice that handles data retrieval, depending on your website's user load.

If you're looking to optimize your API's performance, consider the following strategies:

  1. Optimize Database Queries: Ensure your database queries are efficient. For instance, adding appropriate indexes to your tables can significantly speed up query execution.

  2. Optimize Backend Queries: If you're using an Object-Relational Mapping (ORM) tool, configure it to execute queries on the server side rather than the database side to reduce unnecessary data transfer.

  3. Implement Caching Mechanisms: Introduce caching to store frequently accessed data, which can reduce round trips to your database and improve response times.

The effectiveness of these strategies will depend on your specific architecture. In some cases, scaling your infrastructure, such as the read-microservice, might suffice. In others, a more significant architectural change could be necessary to meet your SLAs.

For example, I've used Redis Enterprise, which offers an ORM to execute queries directly against it. Indexes are created at the Redis level, and data needs to be migrated to Redis as well. While this approach is faster than using traditional databases, it comes with associated costs. It allows you to maintain your response SLAs, depending on the number of transactions per second you need to handle. To determine the appropriate tier of Redis, analyze your concurrent user count and the resulting transactions per second.

For instance, Uber needed to handle 40 million reads per second and utilized Redis Enterprise to achieve this.

https://www.uber.com/blog/how-uber-serves-over-40-million-reads-per-second-using-an-integrated-cache/

There are multiple patterns when using Redis as the primary database. The write-behind pattern involves writing data to Redis, which then asynchronously updates your main database. This approach can help manage load spikes and ensure data consistency over time ( Redis ).

In summary, to enhance performance and meet stringent SLAs, it's essential to assess and possibly restructure your read operations, optimize database interactions, and consider advanced caching strategies tailored to your application's needs.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.