Skip to content

Web application example using elgopher/batch package

License

Notifications You must be signed in to change notification settings

elgopher/batch-example

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Batch example

Web application example using github.com/elgopher/batch package.

How to run?

  • Install docker, docker-compose, curl

  • Start web application with Postgres database

$ docker-compose up

  • Buy a train ticket

$ curl -v "http://localhost:8080/book?train=batchy&person=elgopher&seat=3"

Load testing

You can run script.js in K6 by executing:

$ docker run --network batch-example_default --rm -i grafana/k6 run - <script.js

Why optimistic locking was used?

Because optimistic locking does not require having long-running transactions, which in turn consume database connections. This is especially important here, because batches takes significant amount of time (more than 100ms). With the use of optimistic locking this example application could handle 100k+ requests per second using just 100 database connections.