Giter Site home page Giter Site logo

nodejs-mysql's Introduction

NodeJS + MySql

Using NodeJS with MySql

dev-example.js

Sample code to get started for learning purposes (not fit for production) which connects to the database and performs an SQL query. This runs for standalone connections i.e. one connection at a time (but in reality you may get 100 or even 1000 connections in one particular time and your server should queue the requests if it is not powerful enough to serve them.)

Run

node dev-example.js

prod-example.js

Code for production that tests concurrent users using Pooling. Connection Pooling is a mechanism to maintain a cache of database connections. This way, that connection can be reused after releasing it.

Run

node prod-example.js

Testing concurrency

Install siege

sudo apt-get install siege

Run the following command while the app is running to fire 10 concurrent users for 1 minute.

siege -c10 -t1M http://localhost:3000

The 100-connection limit in code means that if we fire 1000 concurrent users and our MySQL server is configured to handle such traffic at one socket, then it will run and our code will manage the scheduling of concurrent connections. It will serve 100 connections a time but the remaining 900 will be in queue. Thus, the code will not break.

siege -c1000 -t1M http://localhost:3000

nodejs-mysql's People

Contributors

antosan avatar

Stargazers

Roman avatar

Watchers

James Cloos avatar  avatar

Forkers

dheerajrao5

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.