madsim-rs / madsim

Magical Deterministic Simulator for distributed systems in Rust.
Apache License 2.0
686 stars 48 forks source link

How to add support for a few more services like AWS DynamoDB and Google Cloud Spanner? #220

Open quettabit opened 5 months ago

quettabit commented 5 months ago

hey @wangrunji0408!

thank you for putting out this great library. we are currently evaluating between turmoil and madsim. i'm seeing a good amount of work (different ones though given our current state) required on our end either ways, so would like to pick your brain that will be very helpful.

to begin with, i'm only concerned with DynamoDB.

i took a quick look on previous similar discussions/attempts like https://github.com/madsim-rs/madsim/pull/107 and https://github.com/madsim-rs/madsim/issues/122#issuecomment-1429806625 and have got some intuitions re: how to go re: DynamoDB support.

i'd like to hear your recommendations specifically for DynamoDB, in case i'm missing things.

wangrunji0408 commented 5 months ago

Hi. Thank you for your interest. In short, to simulate an external system in madsim, you need to create a madsim-based mock for the third-party library. This includes a single-threaded server-side mock and a client-side mock that communicates with it using madsim internal APIs.

For DynamoDB, I need to know which library you use to interact with DynamoDB in your project. If you're using aws-sdk-dynamodb, it has a similar structure to aws-sdk-s3, so madsim-aws-sdk-s3 could be a useful reference.

To implement this simulator, start with a blank project and patch it into your project as aws-sdk-dynamodb. Then, try to fix compilation errors, leaving many todo!(). This will give you a subset of APIs that you need to implement. Next, you just need to mock these APIs. We might provide a developer guide with technical details in the future.

Regarding the comparison with turmoil, as far as I know, turmoil simulates the network at a lower TCP layer, while madsim works at a higher level. madsim can transfer in-memory data structures directly from client to server without serialization. This makes simulations more efficient but requires more code to implement the simulator.

Please let me know if there’s anything we need to do. I would be happy to help.

quettabit commented 5 months ago

awesome. thank you so much for the deets and the pointers.

yeah, we are indeed using aws-sdk-dynamodb. cool, i'll try to play with it based on your suggestions.