Skip to content

Project-Atelier/products-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

70 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

E-Commerce Products Service

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.

Build with

JavaScript NodeJS NPM Express.js Postgres Sequelize Jest AWS Nginx

Other Libraries Used

  • Loader.io
  • New Relic
  • K6
  • Pactum

Project Accomplishments

  • 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

Test Results

截屏2021-11-30 11 22 17

截屏2021-12-02 14 10 38

Building and running

First install dependencies:

npm install

Start Application:

npm run start

PostgreSQL

Import 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');

Test

Run Jest Test Code:

npm run test

Connect to New Relic:

node -r newrelic server/index.js

Start Stress Testing with K6:

// Change into testing directory
cd testing/k6
k6 run <file name>

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •