Part of a team tasked with building scalable microservices that replaced the legacy monolithic API for an e-commerce platform to handle the increase in growing traffic. This is for the product section of the API and was stress tested using only EC2 t2.micro instances.
- Loader.io
- New Relic
- K6
- Pactum
- Seeded a PostgreSQL database with over 7 million records
- Optimized sequelize ORM query execution times to average < 1ms per query by hash indexing
- Locally optimized to 1000 requests per second with <20 ms latency
- Improved throughput to 10,000 requests per second with <50 ms latency and 0% error rate when deployed and horizontally scaled
- Used total of five EC2 t2.micro instances:
- One instance hosting Postgres database
- One instance running NGINX with least connections load balancing and caching enabled.
- Three instances running the node server with the API
First install dependencies:
npm installStart Application:
npm run startImport data(order maters):
COPY "Products" (id, name, slogan, description, category, default_price) FROM 'filepath/product.csv' WITH (delimiter ',' csv header);
COPY "Styles" (id, "productId", name, sale_price, original_price, default_style) FROM 'filepath/styles.csv' WITH (delimiter ',' csv header null 'null');
COPY "Relateds" (id, current_product_id, related_product_id) FROM 'filepath/related.csv' WITH (delimiter ',' csv header);
COPY "Features" (id, product_id, feature, value) FROM 'filepath/features.csv' WITH (delimiter ',' csv header null 'null');
COPY "Skus" (id, "styleId", size, quantity) FROM 'filepath/skus.csv' WITH (delimiter ',' csv header null 'null');
COPY "Photos" (id, "styleId", url, thumbnail_url) FROM 'filepath/photos.csv' WITH (delimiter ',' csv header null 'null');Run Jest Test Code:
npm run testConnect to New Relic:
node -r newrelic server/index.jsStart Stress Testing with K6:
// Change into testing directory
cd testing/k6
k6 run <file name>
