Code Monkey home page Code Monkey logo

python-tarantool-benchmark-and-bootstrap's Introduction

Python and Tarantool Benchmark and Bootstrap

This is demo project for my article on GitBook and Medium.

Live demo

Purpose

  • The main goal of the project was benchmark Tarantool and Python async web servers performance.
  • Minor task was to show how you could write solution with Tarantool and aiohttp, sanic and japronto libraries.

Installation

You can install the project on your own server by reproducing bash commands described in install.md.

Main steps to setup project is:

  • install Python (pyenv used)
  • install Python libs (requerments.txt)
  • install Tarantool
  • configure Tarantool (pygbu.lua configuration script provided)
  • get some stickers' data into you Tarantool (tests/externalapitotarantool.py) from API hosted at stickers.teslarnd.ru/stickers
  • (optional) install PostgreSQL
  • (optional) configure PostgreSQL
  • (optional) migrate data from Tarantool to PostgreSQL (tests/pgtotarantool.py)

This is not

  • good example of programming style (everything could be code better)
  • only one possible way to solve problem, read code comments (there are hints how to make code better)
  • well-tested software (there are known errors and issues)

How it works

Our web site consists of 5 sections.

  • Index is making the votes and shows 2 images for us to choose one. We have 9 requests to Tarantool for index page:
    • 2 selects for getting a random picture (2 select, 1 insert for each):
      • select from Tarantool random number (call build in function)
      • select from Tarantool token (eval md5 calculation for previously selected number)
      • insert token in space secret
    • create and insert uuid for user session (1 select, 1 upsert):
      • select from Tarantool uuid for session (eval uuid calculation)
      • upsert user information with uuid in session space
    • update server statistics (1 update)
  • Good section showing 9 top rated stickers. We have 3 requests for Good page:
    • select top 9 stickers from 16k records (table) space it Tarantool (it like select top(9) from stickers order by rating ASC)
    • create and insert uuid for user session (1 select, 1 upsert):
      • select from Tarantool uuid for session (eval uuid calculation)
      • upsert user information with uuid in session space
  • Bad section showing us 9 worst rated stickers. Bad runs the same as Good section. 3 requests in total.
  • Ugly section writes text "Ugly", there’re no calculations here. So we can benchmark how fast the web server is.
  • About section renders the template, pastes Title and generates HTML response.

We have stickers api at http://hostname:port/stickers.

License MIT

Project License can be found here.

python-tarantool-benchmark-and-bootstrap's People

Contributors

valentinmk avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Forkers

enixdark

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.