warp-contracts / gateway

A meta-gateway for Arweave SmartWeave interaction transactions.
29 stars 10 forks source link

(1-1) Use AWS Aurora instead of "raw" Postgres instance #91

Open ppedziwiatr opened 2 years ago

ppedziwiatr commented 2 years ago

"infinite scalability" blah blah blah.

Work already in progress.

Test cluster https://eu-north-1.console.aws.amazon.com/rds/home?region=eu-north-1#database:id=tst-aurora-migration-2-cluster;is-cluster=true;tab=connectivity

ppedziwiatr commented 2 years ago

Some benchmarks: 16.170.224.226 - preprod (exact same config as prod), oldschool psql on AWS RDS, db.m6g.large 13.53.39.138 - aurora Serverless v2 (0.5 - 16 ACUs)

Autocannon config:

connections: 5,
  pipelining: 1, 
  duration: 10, 
  workers: 2,
  1. /gateway/interactions-contract-groups?group=all_pst&limit=1000

    image
  2. /gateway/v2/interactions-sort-key?contractId=Daj-MNSnH55TDfxqC7v4eq0lKzVIwh98srUaWqyuZtY&fromSDK=true

    image
  3. /gateway/contracts

    image
  4. /gateway/search/warp

    image
ppedziwiatr commented 2 years ago

turns out I was testing on a wrong Aurora instance 🤡

The proper one is database-1.cluster-cjz2pdvgbj34.eu-north-1.rds.amazonaws.com

https://eu-north-1.console.aws.amazon.com/rds/home?region=eu-north-1#database:id=database-1;is-cluster=true;tab=connectivity

ppedziwiatr commented 2 years ago
  1. /gateway/interactions-contract-groups?group=all_pst&limit=1000

Aurora:

image

Psql:

image
ppedziwiatr commented 2 years ago

/gateway/v2/interactions-sort-key?contractId=Daj-MNSnH55TDfxqC7v4eq0lKzVIwh98srUaWqyuZtY&fromSDK=true

Aurora:

image

Psql:

image
ppedziwiatr commented 2 years ago

/gateway/contracts

Aurora:

image

Psql:

image
ppedziwiatr commented 2 years ago

/gateway/search/warp

Aurora:

image

psql:

image
ppedziwiatr commented 2 years ago

In general - Aurora wins - but behaves kinda "unstable". e.g. I've run the /gateway/contracts endpoint test again (the only one that Aurora lost in the first round) - and now the results are much better:

image

It looks like Aurora needs more time to reach its peak performance (i.e. to "warm up" properly) - and then keeps this peek performance for some period of time.

The "raw" psql instance gives more stable results - let's say it works in a "chu*owo, ale stabilnie" fashion ;-)

In general - we can go on with Aurora (at least from the performance perspective - I still need to make some integration testing). The only question that remains - what will be the cost? ;-)

ppedziwiatr commented 2 years ago

Made some more tests (contracts deployment, sending interactions, reading state, etc), looking good so far...I believe we can go with the deployment! giphy (1)

ppedziwiatr commented 2 years ago

more testing done (for all kind of contract deployments - js/wasm, full or from existing source), bundling interactions, reading state, etc - it works.

ppedziwiatr commented 1 year ago

We need to discuss alternatives (if we plan to move to GCP). Candidates: SQL:

  1. Aurora (if we plan to stay on AWS) - fully postgres compatible
  2. Some Postgres-compatible db on GCP (pg_advisory_locks and gin indexes)

NoSQL:

  1. DynamoDB (probably out of the question because of the 300kb entry size limit)
  2. MongoDB
  3. ScyllaDB (probably most performant, but not sure about pricing/cloud model - we could talk with my friend https://www.linkedin.com/in/piotrjastrzebski/ - though he no longer works at Scylla)
  4. Cassandra
  5. ???

Requirements:

  1. blazingly fast writes (sequencer!)
  2. fast reads ;-) (mostly queries for interactions)
  3. auto-scaling, blah blah