Coder Social home page Coder Social logo

araujo88 / multithreaded-server-c Goto Github PK

View Code? Open in Web Editor NEW
1.0 1.0 0.0 46 KB

Multithreaded server implementation in C using websockets and POSIX threads

License: GNU General Public License v3.0

C 98.01% Shell 0.38% Makefile 1.61%
multi-threaded-server websockets-server websockets multithreading posix-threads pthreads pthreads-api multithreaded-server

multithreaded-server-c's Introduction

multithreaded-server-c

Description

Multithreaded server implementation in C using websockets and POSIX threads. A single-threaded server perfomance is compared with a multi-threaded server perfomance using the time tool.

Installation

Run make all inside the folders "multithread" and "single-thread".

Comparing perfomance

The bash script manyclients.bash will run, at the same time, 50 requests from the client to the server (check client.c for details).

Single-threaded server

In "single-thread" folder, run ./server. This will make the single-threaded server start listening (port 9002). Then, at another terminal, run time ./manyclients.bash. This will run 50 concurrent requests to the server. At the end of the script, the following results should appear, which should differ depending on your machine perfomance:

real  0m2.262s
user  0m0.004s
sys   0m0.004s

Multi-threaded server

For the multi-threaded server, go to the folder "multithread" and run ./server to start the server. This will make the multi-threaded server start listening (port 9002). Then, at another terminal, run time ./manyclients.bash. This will run 50 concurrent requests to the server. At the end of the script, the following results should appear, which should differ depending on your machine perfomance:

real	0m0.018s
user    0m0.000s
sys     0m0.008s

As seen from the results, the multi-threaded server was around 125 times faster than the single-threaded server.

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.