Project developed to participate in the "Rinha de Backend" challenge. The aim of the challenge is to create an API for manipulating people's data, with cache, database and a load balancer to manage two instances, all in a limited environment with 1.5vCPUs and 3GB of memory.
- SOLID
- API REST
- Resource optimization
- Queries with Spring Data R2DBC
- Data caching for faster queries
- Dependency Injection
- Automated tests
- Containerization with docker
- Load Distribution with Load Balancer
In the project, an example environment variables file will be available. The project will start using it, if you want to change the database user and password, or some other value, feel free
-
Clone git repository with modules
git clone https://github.com/WeversonL/rinha-backend.git cd rinha-backend
-
Start with docker-compose
docker-compose up -d
You can access the API via load balancer, sending requests to localhost:9999. Due to resource limitations, it is necessary to wait a while for the entire application to be up and running.
The endpoints offered are based on those requested by the challenge!!
To make the HTTP requests below, the httpie tool was used:
- Create a person
$ http POST :9999/pessoas apelido="nickname" nome="My Name" nascimento="2003-01-22" stack:='["Java", "C", "Python"]'
[
{
"id": "b987f790-7c92-42ca-ab99-2358adcd5e38",
"nome": "My Name",
"apelido": "nickname",
"nascimento": "2003-01-22",
"stack": [
"Java",
"C",
"Python"
]
}
]
- Get person by id
$ http GET :9999/pessoas/{id}
[
{
"id": "b987f790-7c92-42ca-ab99-2358adcd5e38",
"nome": "My Name",
"apelido": "nickname",
"nascimento": "2003-01-22",
"stack": [
"Java",
"C",
"Python"
]
}
]
- Get person by term
In this endpoint you can search for people by any term. It will check whether the term entered appears in any of the columns. For example, knowing if there is someone in my bank who has a STRING with the value "John"
$ http GET ':9999/pessoas?t=nickname'
[
{
"id": "b987f790-7c92-42ca-ab99-2358adcd5e38",
"nome": "My Name",
"apelido": "nickname",
"nascimento": "2003-01-22",
"stack": [
"Java",
"C",
"Python"
]
}
]
$ http GET ':9999/pessoas?t=2003-01-22'
[
{
"id": "b987f790-7c92-42ca-ab99-2358adcd5e38",
"nome": "My Name",
"apelido": "nickname",
"nascimento": "2003-01-22",
"stack": [
"Java",
"C",
"Python"
]
}
]
$ http GET ':9999/pessoas?t=python'
[
{
"id": "b987f790-7c92-42ca-ab99-2358adcd5e38",
"nome": "My Name",
"apelido": "nickname",
"nascimento": "2003-01-22",
"stack": [
"Java",
"C",
"Python"
]
}
]
Rinha Backend
is MIT licensed.