GithubHelp home page GithubHelp logo

gotham_pool_test's Introduction

Gotham Database Pooling Test

This was a quick and dirty test to see if I could get connection pooling working with the gotham web framework and compare whether it was worth it compared to setting up the connection during each handler initialization.

The three endpoints are of this simple webservice are:

  • http://127.0.0.1:9292/ - fixed_handler, the control does not make any database connection does all of the work that isn't related to interactions with Redis.
  • http://127.0.0.1:9292/direct - direct_handler, establishes a new connection to redis with every request increments a counter and returns it as part of the request.
  • http://127.0.0.1:9292/pool - pool_handler, use an r2d2 pool that has been pre-setup and checks out a connection with each request. Still increments a single key and formats and returns the result.

The pool is a bit naive and likely could be improved by writing custom middleware that clones the pool for each request ahead of time rather than using a bulky mutex around it and sharing the pool object itself each request. This was just the fastest / most naive way to perform a basic test.

This should work with any database that can be pooled with r2d2 such as PostgreSQL by replacing the appropriate setup.

Test Results

The following was the results of the test using ab -t 30 ${ENDPOINT} on my personal laptop compiled in release mode with rustc 1.33.0-nightly (7164a9f15 2019-01-21). Your results may vary from mine but these results will likely give you a rough idea of the differences.

Fixed Direct Pool
Reqs/sec 10,428.94 1,513.19 5,204.85

Even with this naive pool implementation it clearly is a major improvement.

gotham_pool_test's People

Contributors

sstelfox avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.