Server Architecture
MA2018
Bogdan Sergiienko
What is server?
Hardware or software that provides functionality for other
programs/devices like:
● Web server
● Application Server
● Mail server
● File server
● Proxy server
● etc
Server roles and design
For web application development context main servers roles
are:
● Web server - serve static HTML and resources
● Application server - serves logical part of a web
application
● Proxy/gateway/load balancing server - simplifies access
to the application servers and balance load between
nodes
The most simple web server in
Node.js
const http = require('http')
const port = 3000
const requestHandler = (request, response) => {
console.log(request.url)
response.end('Hello Node.js Server!')
}
const server = http.createServer(requestHandler)
server.listen(port, (err) => {
if (err) {
return console.log('something bad happened', err)
}
console.log(`server is listening on ${port}`)
})
The most simple web server in
Ruby
require 'socket'
server = TCPServer.new 5678
while session = server.accept
request = session.gets
puts request
session.print "HTTP/1.1 200rn" # 1
session.print "Content-Type: text/htmlrn" # 2
session.print "rn" # 3
session.print "Hello world! The time is #{Time.now}" #4
session.close
end
The most simple HTTP client
k8test@k8test:~$ telnet google.com 80
Trying 216.58.215.110...
Connected to google.com.
Escape character is '^]'.
GET /
HTTP/1.0 200 OK
Server response headers
Date: Wed, 24 Oct 2018 10:25:44 GMT
Expires: -1
Cache-Control: private, max-age=0
Content-Type: text/html; charset=ISO-8859-1
P3P: CP="This is not a P3P policy! See g.co/p3phelp for more info."
Server: gws
X-XSS-Protection: 1; mode=block
X-Frame-Options: SAMEORIGIN
Set-Cookie: 1P_JAR=2018-10-24-10; expires=Fri, 23-Nov-2018 10:25:44 GMT; path=/;
domain=.google.com
Set-Cookie: 123456; expires=Thu, 25-Apr-2019 10:25:44 GMT; path=/; domain=.google.com;
HttpOnly
Accept-Ranges: none
Vary: Accept-Encoding
Web server + Application server
Web server Application server
GET /
Browser
GET /style.css
GET /logo.png
Web server/Load balancer
Web server
+
Load balancer
Application server
GET /
Browser
GET /style.css
GET /logo.png
Application server
Application server
Popular web servers
VDS/VDS/Cloud Server
comparison
Type Pros: Cons:
VDS ● Best performance
● Full control over hardware
● Full responsibility for
backups, health check,
etc
● Long setup process
VPS ● Moderate initialization
time
● Some additional services
like backup and services
are available
● Hardware resources are
shared
Cloud server ● Cloud infrastructure saves
efforts
● Zero control over
hardware and server
location is fluid
Cloud platforms
● Digital Ocean ● Amazon AWS
● Google Cloud Platform
● Microsoft Azure

Server architecture

  • 1.
  • 2.
    What is server? Hardwareor software that provides functionality for other programs/devices like: ● Web server ● Application Server ● Mail server ● File server ● Proxy server ● etc
  • 3.
    Server roles anddesign For web application development context main servers roles are: ● Web server - serve static HTML and resources ● Application server - serves logical part of a web application ● Proxy/gateway/load balancing server - simplifies access to the application servers and balance load between nodes
  • 4.
    The most simpleweb server in Node.js const http = require('http') const port = 3000 const requestHandler = (request, response) => { console.log(request.url) response.end('Hello Node.js Server!') } const server = http.createServer(requestHandler) server.listen(port, (err) => { if (err) { return console.log('something bad happened', err) } console.log(`server is listening on ${port}`) })
  • 5.
    The most simpleweb server in Ruby require 'socket' server = TCPServer.new 5678 while session = server.accept request = session.gets puts request session.print "HTTP/1.1 200rn" # 1 session.print "Content-Type: text/htmlrn" # 2 session.print "rn" # 3 session.print "Hello world! The time is #{Time.now}" #4 session.close end
  • 6.
    The most simpleHTTP client k8test@k8test:~$ telnet google.com 80 Trying 216.58.215.110... Connected to google.com. Escape character is '^]'. GET / HTTP/1.0 200 OK
  • 7.
    Server response headers Date:Wed, 24 Oct 2018 10:25:44 GMT Expires: -1 Cache-Control: private, max-age=0 Content-Type: text/html; charset=ISO-8859-1 P3P: CP="This is not a P3P policy! See g.co/p3phelp for more info." Server: gws X-XSS-Protection: 1; mode=block X-Frame-Options: SAMEORIGIN Set-Cookie: 1P_JAR=2018-10-24-10; expires=Fri, 23-Nov-2018 10:25:44 GMT; path=/; domain=.google.com Set-Cookie: 123456; expires=Thu, 25-Apr-2019 10:25:44 GMT; path=/; domain=.google.com; HttpOnly Accept-Ranges: none Vary: Accept-Encoding
  • 8.
    Web server +Application server Web server Application server GET / Browser GET /style.css GET /logo.png
  • 9.
    Web server/Load balancer Webserver + Load balancer Application server GET / Browser GET /style.css GET /logo.png Application server Application server
  • 10.
  • 11.
    VDS/VDS/Cloud Server comparison Type Pros:Cons: VDS ● Best performance ● Full control over hardware ● Full responsibility for backups, health check, etc ● Long setup process VPS ● Moderate initialization time ● Some additional services like backup and services are available ● Hardware resources are shared Cloud server ● Cloud infrastructure saves efforts ● Zero control over hardware and server location is fluid
  • 12.
    Cloud platforms ● DigitalOcean ● Amazon AWS ● Google Cloud Platform ● Microsoft Azure