Skip to content
This repository was archived by the owner on Nov 2, 2024. It is now read-only.

Atelier API is a high-performance e-commerce backend in Node.js with RESTful endpoints and a SQL database, built to handle production-level traffic.

Notifications You must be signed in to change notification settings

spencerlepine/atelier-ecommerce-api

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Project Atelier API CI Coverage Status

Hack Reactor System Design Capstone Project, which involved scaling the Node.js RESTful API to handle x50 more traffic and reducing p90 latency to ~70ms (-95%). Developed NGINX load-balancer, optimized the PostgreSQL database, and preformed load-testing with K6 and Loader.io.

NodeJS Docker AWS EC2 Postgres Nginx

🌟 Project Overview:

Situation: Refactoring a Node.js RESTful API deployed on AWS EC2, serving retail product data from a PostgreSQL database.

Task: Optimize and scale the API to handle production level traffic with low latency and <1% error rate. This backend was crucial to have ready for the next project, which was the frontend serving this data. It was a challenge without using a Kubernetes cluster or database sharding.

Action: Dockerized the API for horizontal scaling with the NGINX proxy service. Used the dynamic least connection algorithm for load balancing to distribute traffic. Optimized the Node.js app with caching, refactoring database queries, and other minor code improvements. Identified and resolved system bottlenecks with load testing using K6 and Loader.io.

Result: Achieved traffic from <10 RPS to reliable 700 RPS with 70 ms average latency and <1% error rate. Avoided breaking changes with testing and continuous integration, decreasing the stress testing cycle length to allow quick iteration of the system..

📈 Preformance Results

Target Preformance

  • Throughput: 100 RPS
  • Latency: 2000 ms
  • Error rate: <1% rate

Actual Preformance

  • Throughput: ~700 RPS (Max 5000 RPS)
  • Latency: ~70 ms
  • Error rate: <1% rate

System Architecture

Architecture Diagram

📦 Technologies:

⚙️ Local Development

# [optional] Run the local postgres database
$ cd postgres_db
$ docker-compose up -d --build

# Start up the Node/Express server
$ cd server/app
$ npm install
$ cp .env.sample .env

# Update the DATABASE_URL environment variable
EXAMPLE_URL=postgresql://<username>:<password><host>:5432/<database>

🌐 API Documentation

See ATELIER_API_DOCS.md to view the endpoint schema

🗃️ Ticket System

Check out the Trello Scrum Board used to plan user stories and create tasks during development.

Engineering Journal

Read about learning/challenges of this project:

About

Atelier API is a high-performance e-commerce backend in Node.js with RESTful endpoints and a SQL database, built to handle production-level traffic.

Topics

Resources

Stars

Watchers

Forks

Languages

  • JavaScript 96.1%
  • Shell 3.2%
  • Dockerfile 0.7%