A simple but fast URL shortener built using FastAPI, PostgreSQL, and Redis.
System info:
- Memory: 16GB
- CPU: 8 cores
Redirect Result:
- Read from Redis(Cache): RPS(request per second) ≅ 900
- Read from Postgresql: RPS(request per second) ≅ 400
- AVG response time ≅ 200ms
To run the project locally, follow these steps:
- Docker
- Docker Compose
- Clone the repository:
git clone https://github.com/Mohsen-Khodabakhshi/url-shortener.git cd url-shortener
- Setup configuration file:
cp src/.env.sample src/.env
- Run using docker-compose:
docker-compose up --build
- Python 3.10.12
- Poetry 1.8.3
- Postgresql
- Redis
- Clone the repository:
git clone https://github.com/Mohsen-Khodabakhshi/url-shortener.git cd url-shortener/src
- Setup configuration file:
cp .env.sample .env
- Install dependencies:
poetry install
- Database migrations:
poetry run alembic upgrade head
- Run project:
poetry run uvicorn core.main:app --host 127.0.0.1 --port 8000
Contributions are welcome! To contribute to this project, please follow these steps:
- Fork the repository.
- Create a new branch
- Make your changes.
- Install pre-commit hooks:
pip install pre-commit pre-commit install
- Commit your changes
- Push to your branch
- Submit a pull request.