Sign inSign up

weversonlemos/rinha-backend

By weversonlemos

•Updated over 2 years ago

Backend challenge running on limited resources

Image
0

410

weversonlemos/rinha-backend repository overview

⁠ Rinha Backend

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.

⁠Technologies

⁠Practices adopted

  • SOLID
  • API REST
  • Resource optimization
  • Queries with Spring Data JDBC
  • Data caching for faster queries
  • Dependency Injection
  • Automated tests
  • Containerization with docker
  • Load Distribution with Load Balancer

⁠Get started

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

  1. Clone git repository with modules

    git clone https://github.com/WeversonL/rinha-backend.git
    cd rinha-backend
    
⁠Running the application with docker-compose
  1. 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.

⁠API Endpoints

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="2000-01-22" stack:='["Java","C", "Python"]'

[
    {
        "id": "b987f790-7c92-42ca-ab99-2358adcd5e38",
        "nome": "Weverson Lemos",
        "apelido": "verso",
        "nascimento": "2003-01-22",
        "stack": [
            "Java",
            "C"
        ]
    }
]
  • Get person by id
$ http GET :9999/pessoas/{id}

[
    {
        "id": "b987f790-7c92-42ca-ab99-2358adcd5e38",
        "nome": "Weverson Lemos",
        "apelido": "verso",
        "nascimento": "2003-01-22",
        "stack": [
            "Java",
            "C"
        ]
    }
]
  • 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=John'

[
    {
        "id": "b987f790-7c92-42ca-ab99-2358adcd5e38",
        "nome": "John Mars",
        "apelido": "John",
        "nascimento": "2003-01-22",
        "stack": [
            "Java",
            "C"
        ]
    }
]

$ http GET ':9999/pessoas?t=2003-01-22'

[
    {
        "id": "b987f790-7c92-42ca-ab99-2358adcd5e38",
        "nome": "John Mars",
        "apelido": "John",
        "nascimento": "2003-01-22",
        "stack": [
            "Java",
            "C"
        ]
    }
]

⁠License

Rinha Backend is MIT licensed⁠.

Tag summary

Content type

Image

Digest

sha256:e62c86e00…

Size

41.1 MB

Last updated

over 2 years ago

docker pull weversonlemos/rinha-backend