SlideShare a Scribd company logo
Architecture of Web Servers
By Nicolas Vanhoren
Not all web
servers are
made equal
There are different types of
architecture resulting in difference
in performances and resource
usage.
But first a little bit of definitions.
Do you know the difference between a program and
a process ?
● A program is a bunch of code
understandable by a computer that is
located on a storage device.
● A process is a copy of a program in the
RAM of a computer that is currently
runned by that computer.
● It’s completely possible that the same
program is runned multiple times, thus
resulting in multiple concurrent
processes. It’s even a common practice.
SSD
program1
RAM
program1_1
program1_2
program1_3
A few facts about
processes
● They all have their own RAM allocated by
the operating system.
● They can communicate with each other
with means similar to network
connections.
I also heard about a thing called “Threads” ?
● They are a feature of all modern
operating systems.
● Threads allow to have multiple
threads of execution within a
single process.
● They share the same memory.
● Due to the risk of inconsistency
with sharing that same memory
they have to rely on locks.
RAM
process1
thread1 thread2 thread3
Now for the web servers architectures
One process, one thread
● Can handle only one request at
a time.
● Is very simple to implement.
● Examples: PHP dev server, a
lot of other dev servers…
● No one really uses this in
production, the inability to
handle concurrent requests
makes this model only suitable
for quick tests.
Client
Process
Multiple processes, one thread per process
● Each process handles one
request max at any given time.
● Number of concurrent requests
is limited by the amount of
processes.
● Relatively high usage of RAM
per max number of concurrent
requests.
● Technologies using it: PHP
Client
Process Process Process
Multiple threads
● The process dispatches requests
to a pool of thread.
● Number of concurrent requests
only limited by the size of the
thread pool. Each thread usually
uses less RAM than a process.
● Can be combined with multiple
processes for best of both
worlds.
● Technologies using it: Python,
Ruby, Java, .NET,...
Client
Thread Thread Thread
Process
Models using alternatives to
threads
Multi-threads applications are nice, but some people still
complain about their performances and limitations. That’s
why multiple technologies (Go, Erlang, Haskell, Node.js,...)
offer alternatives. Here we will focus on one specific model...
Event-based web servers
● An alternative to threads where the
program manually handles context
switches using an event queue.
● Generally allows more parallelism
than multiple threads and is
considered as a more efficient
alternative for a lot of applications.
(Not all.)
● Can still be combined with multi
processed or multithreaded
architectures.
● Technologies using it: Nginx, Node.js,
Python
Client
Process
Thread
Event Event Event
A word about WebSockets
● They are a new specification implemented on all modern browsers.
● Instead of working on a “per request” basis, they allow persistent bi-
directional connexions between a browser and a web server.
● They are immensely useful for a lot of applications (instant messaging,
collaborative applications, notifications, video games,...)
● Multi-processes architectures are almost unable to use them as each
connexion monopolize a full process persistently.
● Multi-threads architectures are not very efficient either because there is still a
limit to the number of threads on a Linux server.
● Event-based architectures are usually considered very effective to use
WebSockets.
Any questions?

More Related Content

PPTX
Zero mq
PDF
Node.js basics
PDF
Node
PPTX
Project Reactor By Example
PPTX
Mulitthread
PPTX
Foolangjs
PDF
Messaging
PPTX
卒研発表
Zero mq
Node.js basics
Node
Project Reactor By Example
Mulitthread
Foolangjs
Messaging
卒研発表

What's hot (18)

PDF
Guest Agents: Support & Implementation
PDF
Microservices - Please, don't
PDF
Services, dependencies, and you
PPTX
threading and multi threading in java
PDF
WebAssembly with Rust
PDF
Export pdf with puppeteer
PDF
Kernel Recipes 2014 - Performance Does Matter
PPTX
Halton Software Peer 2 Peer Meetup #10
PPT
A Practical Event Driven Model
PDF
Node js first look - 2016
PPTX
What does JavaScript
PDF
Dynamo Amazon’s Highly Available Key-value Store
PPTX
Through Meteor to the stars - Developing full-stack SPA's with meteor.js
PPTX
Hyperledger in AWS
PDF
Working with Asynchronous Events
PDF
Consistency Models in New Generation Databases
PDF
JAZOON'13 - Andrej Vckovski - Go synchronized
PDF
Demo: Reflectivity
Guest Agents: Support & Implementation
Microservices - Please, don't
Services, dependencies, and you
threading and multi threading in java
WebAssembly with Rust
Export pdf with puppeteer
Kernel Recipes 2014 - Performance Does Matter
Halton Software Peer 2 Peer Meetup #10
A Practical Event Driven Model
Node js first look - 2016
What does JavaScript
Dynamo Amazon’s Highly Available Key-value Store
Through Meteor to the stars - Developing full-stack SPA's with meteor.js
Hyperledger in AWS
Working with Asynchronous Events
Consistency Models in New Generation Databases
JAZOON'13 - Andrej Vckovski - Go synchronized
Demo: Reflectivity
Ad

Similar to Architecture of web servers (20)

ODP
Concept of thread
PDF
threads (1).pdfmjlkjfwjgliwiufuaiusyroayr
PPTX
Operating Systems R20 Unit 2.pptx
PDF
Threads lecture slides for operating systems
PPTX
Multi threading models
PPTX
Epc 3.ppt
PPSX
webservers
PPTX
Topic 4- processes.pptx
PDF
Web servers presentacion
PPTX
VTU 6th Sem Elective CSE - Module 3 cloud computing
PDF
J threads-pdf
PPTX
W-9.pptx
PDF
Multithreading 101
PDF
Multithreaded Programming in oprating system
PPTX
Choosing the right parallel compute architecture
PPTX
Multi threaded programming
PPTX
Lecture 3 threads
PPTX
Dori Exterman, Considerations for choosing the parallel computing strategy th...
PDF
Node js vs Django: Which is Better Backend Framework.pdf
Concept of thread
threads (1).pdfmjlkjfwjgliwiufuaiusyroayr
Operating Systems R20 Unit 2.pptx
Threads lecture slides for operating systems
Multi threading models
Epc 3.ppt
webservers
Topic 4- processes.pptx
Web servers presentacion
VTU 6th Sem Elective CSE - Module 3 cloud computing
J threads-pdf
W-9.pptx
Multithreading 101
Multithreaded Programming in oprating system
Choosing the right parallel compute architecture
Multi threaded programming
Lecture 3 threads
Dori Exterman, Considerations for choosing the parallel computing strategy th...
Node js vs Django: Which is Better Backend Framework.pdf
Ad

Recently uploaded (20)

PDF
The Internet -By the Numbers, Sri Lanka Edition
PPTX
international classification of diseases ICD-10 review PPT.pptx
PPTX
June-4-Sermon-Powerpoint.pptx USE THIS FOR YOUR MOTIVATION
PDF
An introduction to the IFRS (ISSB) Stndards.pdf
PDF
Introduction to the IoT system, how the IoT system works
PPTX
Internet___Basics___Styled_ presentation
PDF
Unit-1 introduction to cyber security discuss about how to secure a system
PPTX
SAP Ariba Sourcing PPT for learning material
PPTX
presentation_pfe-universite-molay-seltan.pptx
PDF
WebRTC in SignalWire - troubleshooting media negotiation
PPTX
E -tech empowerment technologies PowerPoint
PPTX
Module 1 - Cyber Law and Ethics 101.pptx
PPTX
Introuction about ICD -10 and ICD-11 PPT.pptx
PDF
Paper PDF World Game (s) Great Redesign.pdf
PDF
Decoding a Decade: 10 Years of Applied CTI Discipline
PPTX
introduction about ICD -10 & ICD-11 ppt.pptx
DOCX
Unit-3 cyber security network security of internet system
PDF
The New Creative Director: How AI Tools for Social Media Content Creation Are...
PDF
Tenda Login Guide: Access Your Router in 5 Easy Steps
PDF
Sims 4 Historia para lo sims 4 para jugar
The Internet -By the Numbers, Sri Lanka Edition
international classification of diseases ICD-10 review PPT.pptx
June-4-Sermon-Powerpoint.pptx USE THIS FOR YOUR MOTIVATION
An introduction to the IFRS (ISSB) Stndards.pdf
Introduction to the IoT system, how the IoT system works
Internet___Basics___Styled_ presentation
Unit-1 introduction to cyber security discuss about how to secure a system
SAP Ariba Sourcing PPT for learning material
presentation_pfe-universite-molay-seltan.pptx
WebRTC in SignalWire - troubleshooting media negotiation
E -tech empowerment technologies PowerPoint
Module 1 - Cyber Law and Ethics 101.pptx
Introuction about ICD -10 and ICD-11 PPT.pptx
Paper PDF World Game (s) Great Redesign.pdf
Decoding a Decade: 10 Years of Applied CTI Discipline
introduction about ICD -10 & ICD-11 ppt.pptx
Unit-3 cyber security network security of internet system
The New Creative Director: How AI Tools for Social Media Content Creation Are...
Tenda Login Guide: Access Your Router in 5 Easy Steps
Sims 4 Historia para lo sims 4 para jugar

Architecture of web servers

  • 1. Architecture of Web Servers By Nicolas Vanhoren
  • 2. Not all web servers are made equal There are different types of architecture resulting in difference in performances and resource usage. But first a little bit of definitions.
  • 3. Do you know the difference between a program and a process ? ● A program is a bunch of code understandable by a computer that is located on a storage device. ● A process is a copy of a program in the RAM of a computer that is currently runned by that computer. ● It’s completely possible that the same program is runned multiple times, thus resulting in multiple concurrent processes. It’s even a common practice. SSD program1 RAM program1_1 program1_2 program1_3
  • 4. A few facts about processes ● They all have their own RAM allocated by the operating system. ● They can communicate with each other with means similar to network connections.
  • 5. I also heard about a thing called “Threads” ? ● They are a feature of all modern operating systems. ● Threads allow to have multiple threads of execution within a single process. ● They share the same memory. ● Due to the risk of inconsistency with sharing that same memory they have to rely on locks. RAM process1 thread1 thread2 thread3
  • 6. Now for the web servers architectures
  • 7. One process, one thread ● Can handle only one request at a time. ● Is very simple to implement. ● Examples: PHP dev server, a lot of other dev servers… ● No one really uses this in production, the inability to handle concurrent requests makes this model only suitable for quick tests. Client Process
  • 8. Multiple processes, one thread per process ● Each process handles one request max at any given time. ● Number of concurrent requests is limited by the amount of processes. ● Relatively high usage of RAM per max number of concurrent requests. ● Technologies using it: PHP Client Process Process Process
  • 9. Multiple threads ● The process dispatches requests to a pool of thread. ● Number of concurrent requests only limited by the size of the thread pool. Each thread usually uses less RAM than a process. ● Can be combined with multiple processes for best of both worlds. ● Technologies using it: Python, Ruby, Java, .NET,... Client Thread Thread Thread Process
  • 10. Models using alternatives to threads Multi-threads applications are nice, but some people still complain about their performances and limitations. That’s why multiple technologies (Go, Erlang, Haskell, Node.js,...) offer alternatives. Here we will focus on one specific model...
  • 11. Event-based web servers ● An alternative to threads where the program manually handles context switches using an event queue. ● Generally allows more parallelism than multiple threads and is considered as a more efficient alternative for a lot of applications. (Not all.) ● Can still be combined with multi processed or multithreaded architectures. ● Technologies using it: Nginx, Node.js, Python Client Process Thread Event Event Event
  • 12. A word about WebSockets ● They are a new specification implemented on all modern browsers. ● Instead of working on a “per request” basis, they allow persistent bi- directional connexions between a browser and a web server. ● They are immensely useful for a lot of applications (instant messaging, collaborative applications, notifications, video games,...) ● Multi-processes architectures are almost unable to use them as each connexion monopolize a full process persistently. ● Multi-threads architectures are not very efficient either because there is still a limit to the number of threads on a Linux server. ● Event-based architectures are usually considered very effective to use WebSockets.