- Introduction
- Features
- Installation
- Gatling installation
- Usage
- Personal best result
- License
- Acknowledgments
This project was created to improve my knowledge of FastAPI. The inspiration came from the Rinha de Backend 2023 project, which challenged participants to build a simple API following specific guidelines. The API needed to withstand a 5-minute load test with a minimal number of knockouts (KO's) and operate within limited resources (1.5 CPUs and 3 GB memory).
- FastAPI Integration: Leveraging the powerful FastAPI framework for building APIs.
- Load Testing: Designed to withstand a 5-minute load test with minimal KO's (knockouts).
- Performance Optimization: Optimized for high performance and low latency.
- Dependency Injection: Utilizes FastAPI's dependency injection system for better modularity and testing.
- Automated Testing: Includes unit tests to ensure code quality.
- Deployment Ready: Configured for easy deployment using Docker.
Follow these steps to get the project up and running:
# Clone the repository
git clone [email protected]:rodrigosantiag/backend-fight-2023.git
# Navigate to the project directory
cd backend-fight-2023
# Install dependencies
make install-dev
# Run the project on network mode host
make up
# Run the project on network mode bridge
make up-bridge
# Run unit tests
make test
# Run logs
make logs
# Navigate to the gatling directory
cd teste/gatling
# Run the script installation
./install-gatling
This project runs a Docker Compose file with four services: one PostgreSQL database, two FastAPI APIs, and an Nginx load balancer. All these resources must share a total of 1.5 CPUs and 3 GB of memory.
make nginx
Note: In network mode host
, update the DATABASE_URL
environment variable in the .env
file to connect to the database host localhost
instead of database
(the default value for bridge mode as provided in the .env_sample
file).
make nginx-bridge
With all services up and running, navigate to gatling directory and run the stress test script
cd teste/gatling
./run-test
The stress test takes 5 minutes. At the end of the test, a report will be provided in the terminal.
Here are the results from my best stress test:
This project is licensed under the MIT License. See the LICENSE file for details.