SlideShare a Scribd company logo
1 of 36
–
different Web programming
       Dima Malenko

       for Ruby Meetup
C++
       Win32
       MFC
       CORBA
2002
ASP.NET Web Forms
public class FirstPage: System.Web.UI.Page
{
  public System.Web.UI.WebControls.Label lblMessage;

    private int i = 0;

    protected void Page_Load(object sender, EventArgs e)
    {
      i = i + 1;
      lblMessage.Text = i.ToString();
    }
}
Web Programming Model


         Request with parameters



Client                             Server
              HTML response
How Web Server Works?
• Create socket
• Bind socket
• Listen on socket
    • Accept new connection from a client
    • Receive data from the client
    • Process the request somehow
    • Send response to the client
• Wait for a new connection
How Web Server Works?
• Create socket
• Bind socket
• Listen on socket
                  • Accept new connection from a client
Separate thread




                  • Receive data from the client
                  • Process the request somehow
                  • Send response to the client
• Wait for a new connection
Why the “separate thread”?
How Web Server Works?
• Create socket
• Bind socket
• Listen on socket
                  • Accept new connection from a client
Separate thread




                  • Receive data from the client
                  • Process the request somehow
                  • Send response to the client
• Wait for a new connection
Threads cost
• Memory overhead
  – Default thread stack size in Linux – 8M
• Context switches cost
  – It takes ~2-3µs to switch context in Linux
  – http://blog.tsunanet.net/2010/11/how-long-does-
    it-take-to-make-context.html
C10k
problem
http://www.kegel.com/c10k.html
Non-blocking I/O!
What would you put in front of
      loaded Web site?
Why Nginx?
Ability to handle more than 10,000
simultaneous connections with a
low memory footprint (~2.5 MB
per 10k inactive HTTP keep-alive
connections)




                         Wikipedia
How is that possible?
• Non-blocking networking using fastest
  interface on any given platform
  – kqueue (FreeBSD 4.1+)
  – epoll (Linux 2.6+)
  – rt signals (Linux 2.2.19+)
  – /dev/poll (Solaris 7 11/99+)
  – event ports (Solaris 10)
  – select
  – poll
• Python web framework and async
  networking library
• Originally developed for FriendFeed
• Ideal for long polling, WebSockets and long-
  lived connections




             www.tornadoweb.com
import tornado.ioloop
import tornado.web

class MainHandler(tornado.web.RequestHandler):
  def get(self):
    self.write("Hello, world")

application = tornado.web.Application([
   (r"/", MainHandler),
])

if __name__ == "__main__":
   application.listen(8888)
   tornado.ioloop.IOLoop.instance().start()
Handling Requests
class ProductHandler(tornado.web.RequestHandler):
  def get(self, product_id):
    self.write("Information about " + product_id)

  @tornado.web.authenticated
  def post(self, product_id):
    # store updated product info

application = tornado.web.Application([
   (r"/product/([0-9]+)", ProductHandler)
])
Templates
<html>
 <head>
   <title>{{ title }}</title>
 </head>
 <body>
  <ul>
   {% for item in items %}
    <li>{{ escape(item) }}</li>
   {% end %}
  </ul>
 </body>
</html>

class MainHandler(tornado.web.RequestHandler):
  def get(self):
    items = ["Item 1", "Item 2", "Item 3"]
    self.render("template.html", title="My title", items=items)
And That’s It?
Web Site                    Node
 Show list of currently
                          Runs many real-time
running apps with their
                             applications
         titles




                               App
                           Changes titles
                          whenever it wants
Web Site                      Node
 Show list of currently
                            Runs many real-time
running apps with their
                               applications
         titles




How would you make               App
sure user can see updated
                             Changes titles
titles on the web?          whenever it wants
Web Site                                Node
                          300-400ms
 Show list of currently
                                      Runs many real-time
running apps with their
                                         applications
         titles




What if…                                  App
                                            App
                                             App
                                              App
                                                App
                                                  App
                                        Changes titles
                                         Changes titles
                                      whenever it wants
                                          Changes titles
                                       whenever it wants
                                           Changes titles
                                        whenever it wants
                                             Changes titles
                                         whenever it wants
                                              Changes titles
                                           whenever it wants
                                            whenever it wants
Non-blocking Requests
class AppUpdatesHandler(tornado.web.RequestHandler):
  @tornado.web.asynchronous
  def get(self):
    http = tornado.httpclient.AsyncHTTPClient()
    request = tornado.httpclient.HTTPRequest(
       "http://www.frontend.com", method="POST", ...)
    http.fetch(request, callback=self.on_response)
    self.finish()

 def on_response(self, response):
   if not response.error:
      log.debug("Title updated”)
WebSockets
class WebSocket(websocket.WebSocketHandler):
  def open(self):
    print "WebSocket opened"

 def on_message(self, message):
   print "Message: " + message

 def on_close(self):
   print "WebSocket closed"
How is it possible?

Cooperative Multitasking
How does it work?
• Event loop
  – Tornado.ioloop.IOLoop
  – Level-triggered, uses epoll on Linux and kqueue
    on BSD
• Futures
  – Result of an async operation
Coroutines
class AppUpdatesHandler(tornado.web.RequestHandler):
  @tornado.web.asynchronous
  @tornado.gen.coroutine
  def get(self):
    http = tornado.httpclient.AsyncHTTPClient()
    request = tornado.httpclient.HTTPRequest(
       "http://www.frontend.com",
       method="POST", ...)
    self.finish()
    response = yield http.fetch(request)
    if not response.error:
       log.debug("Title updated”)
Conclusions
• Web has changed, so programmers should
  too
• You want to face C10k problem
• There means to solve it
• Learn to think asynchronously
• Check out www.tornadoweb.org
Questions?




       www.dmalenko.org
    dmalenko@rollapp.com
             @dmalenko

More Related Content

What's hot

Real time server
Real time serverReal time server
Real time serverthepian
 
Building a real life application in node js
Building a real life application in node jsBuilding a real life application in node js
Building a real life application in node jsfakedarren
 
PyCon US 2012 - State of WSGI 2
PyCon US 2012 - State of WSGI 2PyCon US 2012 - State of WSGI 2
PyCon US 2012 - State of WSGI 2Graham Dumpleton
 
用Tornado开发RESTful API运用
用Tornado开发RESTful API运用用Tornado开发RESTful API运用
用Tornado开发RESTful API运用Felinx Lee
 
服务框架: Thrift & PasteScript
服务框架: Thrift & PasteScript服务框架: Thrift & PasteScript
服务框架: Thrift & PasteScriptQiangning Hong
 
Introduction to node.js
Introduction to node.jsIntroduction to node.js
Introduction to node.jsAdrien Guéret
 
Grâce aux tags Varnish, j'ai switché ma prod sur Raspberry Pi
Grâce aux tags Varnish, j'ai switché ma prod sur Raspberry PiGrâce aux tags Varnish, j'ai switché ma prod sur Raspberry Pi
Grâce aux tags Varnish, j'ai switché ma prod sur Raspberry PiJérémy Derussé
 
Web Crawling with NodeJS
Web Crawling with NodeJSWeb Crawling with NodeJS
Web Crawling with NodeJSSylvain Zimmer
 
Multithreading on iOS
Multithreading on iOSMultithreading on iOS
Multithreading on iOSMake School
 
PECL Picks - Extensions to make your life better
PECL Picks - Extensions to make your life betterPECL Picks - Extensions to make your life better
PECL Picks - Extensions to make your life betterZendCon
 
A million connections and beyond - Node.js at scale
A million connections and beyond - Node.js at scaleA million connections and beyond - Node.js at scale
A million connections and beyond - Node.js at scaleTom Croucher
 
Phl mongo-philly-tornado-2011
Phl mongo-philly-tornado-2011Phl mongo-philly-tornado-2011
Phl mongo-philly-tornado-2011hangxin1940
 
PyCon AU 2010 - Getting Started With Apache/mod_wsgi.
PyCon AU 2010 - Getting Started With Apache/mod_wsgi.PyCon AU 2010 - Getting Started With Apache/mod_wsgi.
PyCon AU 2010 - Getting Started With Apache/mod_wsgi.Graham Dumpleton
 
iOS 2 - The practical Stuff
iOS 2 - The practical StuffiOS 2 - The practical Stuff
iOS 2 - The practical StuffPetr Dvorak
 
MFF UK - Advanced iOS Topics
MFF UK - Advanced iOS TopicsMFF UK - Advanced iOS Topics
MFF UK - Advanced iOS TopicsPetr Dvorak
 

What's hot (20)

Real time server
Real time serverReal time server
Real time server
 
Building a real life application in node js
Building a real life application in node jsBuilding a real life application in node js
Building a real life application in node js
 
PyCon US 2012 - State of WSGI 2
PyCon US 2012 - State of WSGI 2PyCon US 2012 - State of WSGI 2
PyCon US 2012 - State of WSGI 2
 
AJAX Transport Layer
AJAX Transport LayerAJAX Transport Layer
AJAX Transport Layer
 
用Tornado开发RESTful API运用
用Tornado开发RESTful API运用用Tornado开发RESTful API运用
用Tornado开发RESTful API运用
 
服务框架: Thrift & PasteScript
服务框架: Thrift & PasteScript服务框架: Thrift & PasteScript
服务框架: Thrift & PasteScript
 
Introduction to node.js
Introduction to node.jsIntroduction to node.js
Introduction to node.js
 
Grâce aux tags Varnish, j'ai switché ma prod sur Raspberry Pi
Grâce aux tags Varnish, j'ai switché ma prod sur Raspberry PiGrâce aux tags Varnish, j'ai switché ma prod sur Raspberry Pi
Grâce aux tags Varnish, j'ai switché ma prod sur Raspberry Pi
 
Web Crawling with NodeJS
Web Crawling with NodeJSWeb Crawling with NodeJS
Web Crawling with NodeJS
 
Introduction to Flask Micro Framework
Introduction to Flask Micro FrameworkIntroduction to Flask Micro Framework
Introduction to Flask Micro Framework
 
Multithreading on iOS
Multithreading on iOSMultithreading on iOS
Multithreading on iOS
 
How do event loops work in Python?
How do event loops work in Python?How do event loops work in Python?
How do event loops work in Python?
 
PECL Picks - Extensions to make your life better
PECL Picks - Extensions to make your life betterPECL Picks - Extensions to make your life better
PECL Picks - Extensions to make your life better
 
A million connections and beyond - Node.js at scale
A million connections and beyond - Node.js at scaleA million connections and beyond - Node.js at scale
A million connections and beyond - Node.js at scale
 
Phl mongo-philly-tornado-2011
Phl mongo-philly-tornado-2011Phl mongo-philly-tornado-2011
Phl mongo-philly-tornado-2011
 
PyCon AU 2010 - Getting Started With Apache/mod_wsgi.
PyCon AU 2010 - Getting Started With Apache/mod_wsgi.PyCon AU 2010 - Getting Started With Apache/mod_wsgi.
PyCon AU 2010 - Getting Started With Apache/mod_wsgi.
 
Python, do you even async?
Python, do you even async?Python, do you even async?
Python, do you even async?
 
iOS 2 - The practical Stuff
iOS 2 - The practical StuffiOS 2 - The practical Stuff
iOS 2 - The practical Stuff
 
MFF UK - Advanced iOS Topics
MFF UK - Advanced iOS TopicsMFF UK - Advanced iOS Topics
MFF UK - Advanced iOS Topics
 
Tatsumaki
TatsumakiTatsumaki
Tatsumaki
 

Viewers also liked

Rapid web development using tornado web and mongodb
Rapid web development using tornado web and mongodbRapid web development using tornado web and mongodb
Rapid web development using tornado web and mongodbikailan
 
Introduction to Tornado - TienNA
Introduction to Tornado - TienNAIntroduction to Tornado - TienNA
Introduction to Tornado - TienNAFramgia Vietnam
 
Özgür Web Günleri 2013 | Python + Tornado + Nginx + Mongodb ile Ölçeklenebili...
Özgür Web Günleri 2013 | Python + Tornado + Nginx + Mongodb ile Ölçeklenebili...Özgür Web Günleri 2013 | Python + Tornado + Nginx + Mongodb ile Ölçeklenebili...
Özgür Web Günleri 2013 | Python + Tornado + Nginx + Mongodb ile Ölçeklenebili...Mehmet Köse
 
Contoh Lembar Catatan Fakta Guru
Contoh Lembar Catatan Fakta GuruContoh Lembar Catatan Fakta Guru
Contoh Lembar Catatan Fakta Guruenesha sie
 

Viewers also liked (6)

Rapid web development using tornado web and mongodb
Rapid web development using tornado web and mongodbRapid web development using tornado web and mongodb
Rapid web development using tornado web and mongodb
 
Tornado
TornadoTornado
Tornado
 
Tornado
TornadoTornado
Tornado
 
Introduction to Tornado - TienNA
Introduction to Tornado - TienNAIntroduction to Tornado - TienNA
Introduction to Tornado - TienNA
 
Özgür Web Günleri 2013 | Python + Tornado + Nginx + Mongodb ile Ölçeklenebili...
Özgür Web Günleri 2013 | Python + Tornado + Nginx + Mongodb ile Ölçeklenebili...Özgür Web Günleri 2013 | Python + Tornado + Nginx + Mongodb ile Ölçeklenebili...
Özgür Web Günleri 2013 | Python + Tornado + Nginx + Mongodb ile Ölçeklenebili...
 
Contoh Lembar Catatan Fakta Guru
Contoh Lembar Catatan Fakta GuruContoh Lembar Catatan Fakta Guru
Contoh Lembar Catatan Fakta Guru
 

Similar to Web Programming Models and Technologies

Beginning MEAN Stack
Beginning MEAN StackBeginning MEAN Stack
Beginning MEAN StackRob Davarnia
 
Advance Java Topics (J2EE)
Advance Java Topics (J2EE)Advance Java Topics (J2EE)
Advance Java Topics (J2EE)slire
 
What is WebDAV - uploaded by Murali Krishna Nookella
What is WebDAV - uploaded by Murali Krishna NookellaWhat is WebDAV - uploaded by Murali Krishna Nookella
What is WebDAV - uploaded by Murali Krishna Nookellamuralikrishnanookella
 
Power Shell and Sharepoint 2013
Power Shell and Sharepoint 2013Power Shell and Sharepoint 2013
Power Shell and Sharepoint 2013Mohan Arumugam
 
Languages and tools for web programming
Languages and tools for web  programmingLanguages and tools for web  programming
Languages and tools for web programmingAlamelu
 
Languages and tools for web programming
Languages and tools for web  programmingLanguages and tools for web  programming
Languages and tools for web programmingalamelumani
 
Rails Request & Middlewares
Rails Request & MiddlewaresRails Request & Middlewares
Rails Request & MiddlewaresSantosh Wadghule
 
TorqueBox - Ruby Hoedown 2011
TorqueBox - Ruby Hoedown 2011TorqueBox - Ruby Hoedown 2011
TorqueBox - Ruby Hoedown 2011Lance Ball
 
Knowledge Sharing : Java Servlet
Knowledge Sharing : Java ServletKnowledge Sharing : Java Servlet
Knowledge Sharing : Java ServletFahmi Jafar
 
Networked APIs with swift
Networked APIs with swiftNetworked APIs with swift
Networked APIs with swiftTim Burks
 
Cross-Platform Native Mobile Development with Eclipse
Cross-Platform Native Mobile Development with EclipseCross-Platform Native Mobile Development with Eclipse
Cross-Platform Native Mobile Development with EclipsePeter Friese
 
Spring Web Services: SOAP vs. REST
Spring Web Services: SOAP vs. RESTSpring Web Services: SOAP vs. REST
Spring Web Services: SOAP vs. RESTSam Brannen
 
Java servlet technology
Java servlet technologyJava servlet technology
Java servlet technologyMinal Maniar
 

Similar to Web Programming Models and Technologies (20)

Day7
Day7Day7
Day7
 
Beginning MEAN Stack
Beginning MEAN StackBeginning MEAN Stack
Beginning MEAN Stack
 
Servlets
ServletsServlets
Servlets
 
Advance Java Topics (J2EE)
Advance Java Topics (J2EE)Advance Java Topics (J2EE)
Advance Java Topics (J2EE)
 
What is WebDAV - uploaded by Murali Krishna Nookella
What is WebDAV - uploaded by Murali Krishna NookellaWhat is WebDAV - uploaded by Murali Krishna Nookella
What is WebDAV - uploaded by Murali Krishna Nookella
 
Power Shell and Sharepoint 2013
Power Shell and Sharepoint 2013Power Shell and Sharepoint 2013
Power Shell and Sharepoint 2013
 
Languages and tools for web programming
Languages and tools for web  programmingLanguages and tools for web  programming
Languages and tools for web programming
 
Languages and tools for web programming
Languages and tools for web  programmingLanguages and tools for web  programming
Languages and tools for web programming
 
Rails Request & Middlewares
Rails Request & MiddlewaresRails Request & Middlewares
Rails Request & Middlewares
 
JAVA Servlets
JAVA ServletsJAVA Servlets
JAVA Servlets
 
5-WebServers.ppt
5-WebServers.ppt5-WebServers.ppt
5-WebServers.ppt
 
TorqueBox - Ruby Hoedown 2011
TorqueBox - Ruby Hoedown 2011TorqueBox - Ruby Hoedown 2011
TorqueBox - Ruby Hoedown 2011
 
Knowledge Sharing : Java Servlet
Knowledge Sharing : Java ServletKnowledge Sharing : Java Servlet
Knowledge Sharing : Java Servlet
 
Advanced JavaScript
Advanced JavaScriptAdvanced JavaScript
Advanced JavaScript
 
Networked APIs with swift
Networked APIs with swiftNetworked APIs with swift
Networked APIs with swift
 
Cross-Platform Native Mobile Development with Eclipse
Cross-Platform Native Mobile Development with EclipseCross-Platform Native Mobile Development with Eclipse
Cross-Platform Native Mobile Development with Eclipse
 
Spring Web Services: SOAP vs. REST
Spring Web Services: SOAP vs. RESTSpring Web Services: SOAP vs. REST
Spring Web Services: SOAP vs. REST
 
AJppt.pptx
AJppt.pptxAJppt.pptx
AJppt.pptx
 
Chapter 5
Chapter 5Chapter 5
Chapter 5
 
Java servlet technology
Java servlet technologyJava servlet technology
Java servlet technology
 

More from Dima Malenko

Where are the new technologies coming from?
Where are the new technologies coming from?Where are the new technologies coming from?
Where are the new technologies coming from?Dima Malenko
 
Nation: technological and/or successful
Nation: technological and/or successfulNation: technological and/or successful
Nation: technological and/or successfulDima Malenko
 
3x3+3 #6 New and old platforms
3x3+3 #6 New and old platforms3x3+3 #6 New and old platforms
3x3+3 #6 New and old platformsDima Malenko
 
Future of the Apps: what startups need to know
Future of the Apps: what startups need to knowFuture of the Apps: what startups need to know
Future of the Apps: what startups need to knowDima Malenko
 
Crises in startups
Crises in startupsCrises in startups
Crises in startupsDima Malenko
 
Magic Triangle: Product, Market, Users
Magic Triangle: Product, Market, UsersMagic Triangle: Product, Market, Users
Magic Triangle: Product, Market, UsersDima Malenko
 
What We Learned From Porting 50+ Cloud Apps to Tizen
What We Learned From Porting 50+ Cloud Apps to TizenWhat We Learned From Porting 50+ Cloud Apps to Tizen
What We Learned From Porting 50+ Cloud Apps to TizenDima Malenko
 
Scaling and Distributing
Scaling and DistributingScaling and Distributing
Scaling and DistributingDima Malenko
 
Evolution of software projects
Evolution of software projectsEvolution of software projects
Evolution of software projectsDima Malenko
 
Как команду соберете, так она и поплывет
Как команду соберете, так она и поплыветКак команду соберете, так она и поплывет
Как команду соберете, так она и поплыветDima Malenko
 
Cultural test by... a door at a mall
Cultural test by... a door at a mallCultural test by... a door at a mall
Cultural test by... a door at a mallDima Malenko
 

More from Dima Malenko (14)

Where are the new technologies coming from?
Where are the new technologies coming from?Where are the new technologies coming from?
Where are the new technologies coming from?
 
Nation: technological and/or successful
Nation: technological and/or successfulNation: technological and/or successful
Nation: technological and/or successful
 
3x3+3 #6 New and old platforms
3x3+3 #6 New and old platforms3x3+3 #6 New and old platforms
3x3+3 #6 New and old platforms
 
Future of the Apps: what startups need to know
Future of the Apps: what startups need to knowFuture of the Apps: what startups need to know
Future of the Apps: what startups need to know
 
Crises in startups
Crises in startupsCrises in startups
Crises in startups
 
Magic Triangle: Product, Market, Users
Magic Triangle: Product, Market, UsersMagic Triangle: Product, Market, Users
Magic Triangle: Product, Market, Users
 
What We Learned From Porting 50+ Cloud Apps to Tizen
What We Learned From Porting 50+ Cloud Apps to TizenWhat We Learned From Porting 50+ Cloud Apps to Tizen
What We Learned From Porting 50+ Cloud Apps to Tizen
 
Scaling and Distributing
Scaling and DistributingScaling and Distributing
Scaling and Distributing
 
Evolution of software projects
Evolution of software projectsEvolution of software projects
Evolution of software projects
 
Browsers
BrowsersBrowsers
Browsers
 
Как команду соберете, так она и поплывет
Как команду соберете, так она и поплыветКак команду соберете, так она и поплывет
Как команду соберете, так она и поплывет
 
Part Time Agile
Part Time AgilePart Time Agile
Part Time Agile
 
Cultural test by... a door at a mall
Cultural test by... a door at a mallCultural test by... a door at a mall
Cultural test by... a door at a mall
 
Just Do It
Just Do ItJust Do It
Just Do It
 

Recently uploaded

TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?Antenna Manufacturer Coco
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEarley Information Science
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CVKhem
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Enterprise Knowledge
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 

Recently uploaded (20)

TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 

Web Programming Models and Technologies

  • 1. – different Web programming Dima Malenko for Ruby Meetup
  • 2. C++ Win32 MFC CORBA 2002
  • 3. ASP.NET Web Forms public class FirstPage: System.Web.UI.Page { public System.Web.UI.WebControls.Label lblMessage; private int i = 0; protected void Page_Load(object sender, EventArgs e) { i = i + 1; lblMessage.Text = i.ToString(); } }
  • 4. Web Programming Model Request with parameters Client Server HTML response
  • 5.
  • 6. How Web Server Works? • Create socket • Bind socket • Listen on socket • Accept new connection from a client • Receive data from the client • Process the request somehow • Send response to the client • Wait for a new connection
  • 7. How Web Server Works? • Create socket • Bind socket • Listen on socket • Accept new connection from a client Separate thread • Receive data from the client • Process the request somehow • Send response to the client • Wait for a new connection
  • 8. Why the “separate thread”?
  • 9. How Web Server Works? • Create socket • Bind socket • Listen on socket • Accept new connection from a client Separate thread • Receive data from the client • Process the request somehow • Send response to the client • Wait for a new connection
  • 10.
  • 11. Threads cost • Memory overhead – Default thread stack size in Linux – 8M • Context switches cost – It takes ~2-3µs to switch context in Linux – http://blog.tsunanet.net/2010/11/how-long-does- it-take-to-make-context.html
  • 12.
  • 15. What would you put in front of loaded Web site?
  • 16.
  • 18. Ability to handle more than 10,000 simultaneous connections with a low memory footprint (~2.5 MB per 10k inactive HTTP keep-alive connections) Wikipedia
  • 19. How is that possible? • Non-blocking networking using fastest interface on any given platform – kqueue (FreeBSD 4.1+) – epoll (Linux 2.6+) – rt signals (Linux 2.2.19+) – /dev/poll (Solaris 7 11/99+) – event ports (Solaris 10) – select – poll
  • 20. • Python web framework and async networking library • Originally developed for FriendFeed • Ideal for long polling, WebSockets and long- lived connections www.tornadoweb.com
  • 21.
  • 22.
  • 23. import tornado.ioloop import tornado.web class MainHandler(tornado.web.RequestHandler): def get(self): self.write("Hello, world") application = tornado.web.Application([ (r"/", MainHandler), ]) if __name__ == "__main__": application.listen(8888) tornado.ioloop.IOLoop.instance().start()
  • 24. Handling Requests class ProductHandler(tornado.web.RequestHandler): def get(self, product_id): self.write("Information about " + product_id) @tornado.web.authenticated def post(self, product_id): # store updated product info application = tornado.web.Application([ (r"/product/([0-9]+)", ProductHandler) ])
  • 25. Templates <html> <head> <title>{{ title }}</title> </head> <body> <ul> {% for item in items %} <li>{{ escape(item) }}</li> {% end %} </ul> </body> </html> class MainHandler(tornado.web.RequestHandler): def get(self): items = ["Item 1", "Item 2", "Item 3"] self.render("template.html", title="My title", items=items)
  • 27. Web Site Node Show list of currently Runs many real-time running apps with their applications titles App Changes titles whenever it wants
  • 28. Web Site Node Show list of currently Runs many real-time running apps with their applications titles How would you make App sure user can see updated Changes titles titles on the web? whenever it wants
  • 29. Web Site Node 300-400ms Show list of currently Runs many real-time running apps with their applications titles What if… App App App App App App Changes titles Changes titles whenever it wants Changes titles whenever it wants Changes titles whenever it wants Changes titles whenever it wants Changes titles whenever it wants whenever it wants
  • 30. Non-blocking Requests class AppUpdatesHandler(tornado.web.RequestHandler): @tornado.web.asynchronous def get(self): http = tornado.httpclient.AsyncHTTPClient() request = tornado.httpclient.HTTPRequest( "http://www.frontend.com", method="POST", ...) http.fetch(request, callback=self.on_response) self.finish() def on_response(self, response): if not response.error: log.debug("Title updated”)
  • 31. WebSockets class WebSocket(websocket.WebSocketHandler): def open(self): print "WebSocket opened" def on_message(self, message): print "Message: " + message def on_close(self): print "WebSocket closed"
  • 32. How is it possible? Cooperative Multitasking
  • 33. How does it work? • Event loop – Tornado.ioloop.IOLoop – Level-triggered, uses epoll on Linux and kqueue on BSD • Futures – Result of an async operation
  • 34. Coroutines class AppUpdatesHandler(tornado.web.RequestHandler): @tornado.web.asynchronous @tornado.gen.coroutine def get(self): http = tornado.httpclient.AsyncHTTPClient() request = tornado.httpclient.HTTPRequest( "http://www.frontend.com", method="POST", ...) self.finish() response = yield http.fetch(request) if not response.error: log.debug("Title updated”)
  • 35. Conclusions • Web has changed, so programmers should too • You want to face C10k problem • There means to solve it • Learn to think asynchronously • Check out www.tornadoweb.org
  • 36. Questions? www.dmalenko.org dmalenko@rollapp.com @dmalenko