Microservices with shared database

0

Hi there,

As is not recommended by "Database per service" design pattern, every integration between microservices should be done with any messaging system?

We have an application where users can upload videos. The API is available using GraphQL, and we have federation to route the video uploads to a cluster of servers responsible to create the video in the database (RDS).

Once the video is uploaded to S3, a service that is triggered by a S3 event start a MediaConvert job to create a HLS profile. Once completed, we need to mark the video as available to viewers (updating the table).

What is the best practice to do this? The convert service should connect to the database and update the record? Execute a service API to update the record? Send a SQS message that will be handle in the cluster that is connected to the database?

  • If below helps, please upvote/accepted. It would be appreciated!

1개 답변
0

The answer is it depends. This is due to number of users, throughput request/seconds and other values.

A suggestion could be to send the S3 event notification to an SQS queue or an SNS Topic. Then the consumer could be a Step Function that has 2 states:

  1. the Media converter.
  2. update of the database. This could be a lambda function which has an RDS proxy integration in front of the RDS database.

In this serverless way, you could retry, keep an eye on the flow, ensure the converter does not get overwhelmed by requests.

profile picture
전문가
답변함 일 년 전
  • Great suggestion, thanks!

    My concern still on the 2nd state of the step function. So would the step function connect to RDS (proxy or not) and not use another service that perform operations in the table?

  • In this scenario I would have the second step using a Lambda or container that connects directly to RDS via using an RDS proxy.

    I see your point of abstracting the db layer by having it responsible to handle db interactions. In my experience it just felt a bit over engineering as it would have pretty much the same role as an RDSProxy, but if you want to create an api that is used as api layer that then calls rds proxy, the there may be more latency and be potentially a bottleneck, but up to you.

    Hope the answer makes good sense and helps you!

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠