SlideShare a Scribd company logo
Event loop 를 이용한 웹 엔진 개발
17.6.16. 최종발표
F조 이기웅, 유종민, 김수
2
Results & Demo
1. Background
2. Goal
3. Diagram
3. Issue
4. Demo
3
Background
Two Types of Web Server
Multi-Threaded Server
Single-Threaded Server
Background
Multi-Threaded Server Shortcomings
• Spawn a new thread for every new http requests
• Overhead of creating a new thread for every requests with simultaneous users access
• Memory allocation with threads
• Overhead with context switching
• In I/O intensive scenarios the requests spend most of the time waiting for I/O to complete
Multi-Threaded Server Shortcomings
Background
Single Thread Server : Alternative of Multi-Thread Server
Single-Threaded Server
• Asynchronous event driven IO which uses thread pool for IO task handling
• Events made from http requests is dealt by Handler/Listener with callback
• Application not to pause or sleep, but to become available for other requests.
• Suitable for implementing Web Server which has Intensive IO task with clients
6
Goal
Goal
• Implementing Web Server Engine which deals with several http requests
Requirements with Stable/Fast Web Server Engine
• Stability - Handle large amounts of simultaneous http requests without crashes
• Performance - High Latency, Low Error Rates
• Reliability - Prevent malicious/abnormal client access
Subgoals
• Implement event loop structure and communication capabilities between event loop/worker threads
• Caching/Buffer to improve performance with IO
• Prevent malicious client access with two representative cases
• Performance comparison with existing web server engines
7
Diagram
서버 주요 모듈
8
Diagram
서버 주요 모듈 - Selector + Event Loop
Selector - Select
Initialization with opening socket
to communicate with clients and
registering server to selector
waiting for requests from clients
Selector - Accept/Read/Write
Selector periodically checking
requests from clients, register
clients to selector and handle
request as an event in event loop
Ready Key(Selected Key)
Selected key retrieved
from selector, which is an event
transformed from client request
9
Diagram
서버 주요 모듈 - HttpParser + Request Processor
HttpParser - parseRequest
Http content from a client
is parsed into hash table,
returning status of http
request
Request Processor - process
If status is 200, keep handling
the process.Otherwise make a

http response with error code
to the client
Error Code
304 - Not Modified
400 - Bad Request
404 - Not Found
500 - Interval Server Error
10
Diagram
서버 주요 모듈 - Event Loop
Request Processor - process
With http request status 200,
if task is light-weight overload
handle the task in event loop.
Otherwise, handle task with

additional async thread
Main Controller - writer
With light-weight overload task
after handling it in process,
make a http response to client
In a format of http message
11
Diagram
서버 주요 모듈 - I/O Thread + Thread Pool + Mem Cache
I/O Thread - handle
From the thread pool, allocate
file IO task to waiting thread
by calling submit function
I/O Thread - loadFile
Following the filePath, read the
file from memory cache if exists.
Otherwise read file from disk.
MainController - writer
Make a http response to client
in a format of http message
12
Issues
Web Cache Replacement Policy에 따른 Performance Optimization
Problem
Latency inefficiency with file I/O task handling
Solution
Find an optimal replacement policy for web cache,
and apply it to memory cache of web server
1.FIFO(First In First Out)
2. LRU(Least Recently Used)
3. LFU(Least Frequently Used)
13
Issues
Web Cache Optimization - Zipf distribution
Zipf Distribution
- A few elements that score very high
(the left tail in the diagrams)
- A medium number of elements with
middle-of-the-road scores
(The middle part of the diagram)
- A huge number of elements that
score very low
(The right part of the diagram)
* LRU Suitable than LFU
14
Issues
Web Cache optimization - Test with LFU/LRU
• LFU - 1,000 Simultaneous clients requests
• LRU - 1,000 Simultaneous clients requests
There was not much
difference between
LFU and LRU Policy
=> Adopted LRU on
caching eviction
14
15
Issues
ByteBuffer Optimization - Kernel Buffer/Heap Buffer
Problem
Reading http request message from clients and writing http response to client,
It is essential to read/write message in a byte buffer. Consuming lots of times,
it becomes one of the reason for delayed latency.
Solution
While considering pros and cons among kernel buffer and heap buffer, apply one
with better performance to obtain optimization.
1.Kernel Buffer
2. Heap Buffer
16
Issues
ByteBuffer Optimization - Kernel Buffer/Heap Buffer
Kernel Buffer Heap Buffer
Definition
Contents of direct buffers reside
outside of the normal garbage-
collected heap
Within JVM, memory where
objects are stored
Pros
Faster to read/write
on memory for filling
With bytes and integers
Allocation and deallocation is
less expensive. GC enabled
Cons
Allocation and deallocation is
more expensive
Slower than kernel buffer due
to GC functionality
17
Issues
ByteBuffer Optimization - Kernel Buffer/Heap Buffer
18
Issues
ByteBuffer Optimization - Kernel Buffer/Heap Buffer
• Heap Buffer - 1,000 Simultaneous clients requests
• Kernel Buffer - 1,000 Simultaneous clients requests
Kernel Buffer outperforms
Heap buffer in aspects of
error rate and throughput.
=> Adopted kernel buffer
by allocateDirect during
initialization of program
19
Issues
Reliability - Malicious/Abnormal Client Request
Problem
Web server confronts various malicious programs/scripts from hackers, at the same
time abnormal client requests. This leads to server crash, so it needs to be prevented.
Problem 1 - Request timeout.
Problem 2 - Request too long.
Solution
Due to the fact that there are numerous kinds of malicious attacks/abnormal requests,
prevent two representative cases by reflecting proper handling logics into the code.
Solution 1 - Register request timeout limit on http request, return 408 error
Solution 2 - Limit buffer size read from client http request, return 400 error
20
Issues
Reliability - Malicious/Abnormal Client Request
• Request timeout
• Request too long
Find request
timeout problem
and return 408
Request timeout
Find request
too long problem
and return 400
Bad Request
21
Issues
Simultaneous multi-client request optimization - Backlog
Problem
Java 기반의 시스템은 메모리를 JVM(Java Virtual Machine)에서 관리하기 때문에 Full GC
발생으로 인한 STW(Stop The World) 현상에서 자유로울 수 없다.	또한 Full GC 발생 시의	
휴지기가 1초에서 4초 이상으로 급격하게 늘어, 시스템이 한 동안 먹통이 되면	
모든 요청에 대해 응답할 수 없는 상태에 빠지게 된다.
Solution
Backlog는 미연결 연결들에 대한 큐의 늘어날 수 있는 최대 길이를 정의한다. 전체 시스템
메모리와 Asynchronous Web Server가 차지하는 Heap의 크기 및 Client당 메모리 점유에 대한
계산을 통해 적절한 Backlog와의 설정이 필요하다.
따라서 Backlog양을 50부터 200까지 10씩 늘려가며 profiling한 결과 최적의 결과값을
보여주는 150으로 설정하였다.
22
Issues
Simultaneous multi-client request optimization - Backlog
• Backlog 50
• Backlog 150
Backlog of 150 outperforms
backlog of 50 in aspects of
error rate and throughput.
=> Adopted backlog 150
in server socket binding
23
Live Demo - Open Browser and apply web server engine onto it
Live Demo
24
Performance Measure
With JMeter
• NodeJS 및 타 비동기 웹 서버와의 비교 기준
• Test Plan #1 : 동시접속자 100명이 1MB 이하
의 File I/O를 총 1000번 정도의 Request
• Criteria : Average Throughput, Average
Response Time, Error Rate
• Test Plan #2 : 동시접속자 1000명이 1MB 이
하의 File I/O를 총 10000번 정도의 Request
• Criteria : Test Plan #1와 동일
25
Live Demo - JMeter Test
Live Demo
26
Division and Assignment of Work
• 김수
- 개발 환경 구축 및 Github 초기 연동 작업
- Http Parser 및 File IO Thread 구현
- Http 프로그래밍 관련 주요 이슈 담당
- 전체 문서 관리
- Caching(LFU/LRU/FIFO) 구현 및 테스트 담당
- Event Loop와 Thread Pool 통신 기능 구현
- JMeter에 의한 테스트셋 구현 및 성능 향상 담당
- 일정 조정 및 커뮤니케이션 담당
- Event Loop 구현 담당
- 소켓 프로그래밍 관련 주요 이슈 담당
• 유종민
• 이기웅
27
Schedule
프로젝트 시작
교수님 면담
3/3
담당자 미팅
3차 구현 완료
스펙 발표
3/31
최종 발표
6/16 2차 구현 완료
1차 구현 완료
6/16
담당자 미팅
3/10
6/9
교수님 면담
3/17
셀렉터 공부
3/16
최적화 진행
중간 발표
5/19
로직 설계
4/3
End of Document
감사합니다.
F 조 김수, 유종민, 이기웅 010.9553.2500. wooong1225@gmail.com

More Related Content

What's hot

LTM essentials
LTM essentialsLTM essentials
LTM essentialsbharadwajv
 
CFIMAP & CFPOP
CFIMAP & CFPOPCFIMAP & CFPOP
CFIMAP & CFPOPisummation
 
Covert Timing Channels using HTTP Cache Headers
Covert Timing Channels using HTTP Cache HeadersCovert Timing Channels using HTTP Cache Headers
Covert Timing Channels using HTTP Cache HeadersDenis Kolegov
 
Java troubleshooting thread dump
Java troubleshooting thread dumpJava troubleshooting thread dump
Java troubleshooting thread dumpejlp12
 
Apache ActiveMQ and Apache ServiceMix
Apache ActiveMQ and Apache ServiceMixApache ActiveMQ and Apache ServiceMix
Apache ActiveMQ and Apache ServiceMixBruce Snyder
 
VerneMQ - Distributed MQTT Broker
VerneMQ - Distributed MQTT BrokerVerneMQ - Distributed MQTT Broker
VerneMQ - Distributed MQTT BrokerAdriano Pimpini
 
ServiceMix 4 -- Integrating OSGi with JBI
ServiceMix 4 -- Integrating OSGi with JBIServiceMix 4 -- Integrating OSGi with JBI
ServiceMix 4 -- Integrating OSGi with JBIGert Vanthienen
 
Reaching 5 Million Messaging Connections: Our Journey with Kubernetes
Reaching 5 Million Messaging Connections:  Our Journey with KubernetesReaching 5 Million Messaging Connections:  Our Journey with Kubernetes
Reaching 5 Million Messaging Connections: Our Journey with KubernetesConnected
 
Benchmarking distributed tracers
Benchmarking distributed tracersBenchmarking distributed tracers
Benchmarking distributed tracersQiao Han
 
Peer Cache for Configuration Manager clients
Peer Cache for Configuration Manager clientsPeer Cache for Configuration Manager clients
Peer Cache for Configuration Manager clientsKarthick Jokirathinam
 
JDKIO: Java EE 8 what Servlet 4 and HTTP2 mean to you
JDKIO: Java EE 8 what Servlet 4 and HTTP2 mean to youJDKIO: Java EE 8 what Servlet 4 and HTTP2 mean to you
JDKIO: Java EE 8 what Servlet 4 and HTTP2 mean to youAlex Theedom
 
Java EE 8: What Servlet 4.0 and HTTP2 mean to you
Java EE 8: What Servlet 4.0 and HTTP2 mean to youJava EE 8: What Servlet 4.0 and HTTP2 mean to you
Java EE 8: What Servlet 4.0 and HTTP2 mean to youAlex Theedom
 
Implementing WebServices with Camel and CXF in ServiceMix
Implementing WebServices with Camel and CXF in ServiceMixImplementing WebServices with Camel and CXF in ServiceMix
Implementing WebServices with Camel and CXF in ServiceMixAdrian Trenaman
 
Covert Timing Channels based on HTTP Cache Headers (Special Edition for Top 1...
Covert Timing Channels based on HTTP Cache Headers (Special Edition for Top 1...Covert Timing Channels based on HTTP Cache Headers (Special Edition for Top 1...
Covert Timing Channels based on HTTP Cache Headers (Special Edition for Top 1...Denis Kolegov
 
Learning j meter in 60 minutes
Learning j meter in 60 minutesLearning j meter in 60 minutes
Learning j meter in 60 minutesAlon Girmonsky
 
J meter introduction
J meter introductionJ meter introduction
J meter introductionBharath Kumar
 

What's hot (20)

LTM essentials
LTM essentialsLTM essentials
LTM essentials
 
CFIMAP & CFPOP
CFIMAP & CFPOPCFIMAP & CFPOP
CFIMAP & CFPOP
 
Covert Timing Channels using HTTP Cache Headers
Covert Timing Channels using HTTP Cache HeadersCovert Timing Channels using HTTP Cache Headers
Covert Timing Channels using HTTP Cache Headers
 
Java troubleshooting thread dump
Java troubleshooting thread dumpJava troubleshooting thread dump
Java troubleshooting thread dump
 
EVCache Builderscon
EVCache BuildersconEVCache Builderscon
EVCache Builderscon
 
Apache ActiveMQ and Apache ServiceMix
Apache ActiveMQ and Apache ServiceMixApache ActiveMQ and Apache ServiceMix
Apache ActiveMQ and Apache ServiceMix
 
VerneMQ - Distributed MQTT Broker
VerneMQ - Distributed MQTT BrokerVerneMQ - Distributed MQTT Broker
VerneMQ - Distributed MQTT Broker
 
ServiceMix 4 -- Integrating OSGi with JBI
ServiceMix 4 -- Integrating OSGi with JBIServiceMix 4 -- Integrating OSGi with JBI
ServiceMix 4 -- Integrating OSGi with JBI
 
HTTP/2 Prioritization
HTTP/2 PrioritizationHTTP/2 Prioritization
HTTP/2 Prioritization
 
Reaching 5 Million Messaging Connections: Our Journey with Kubernetes
Reaching 5 Million Messaging Connections:  Our Journey with KubernetesReaching 5 Million Messaging Connections:  Our Journey with Kubernetes
Reaching 5 Million Messaging Connections: Our Journey with Kubernetes
 
Http2 in practice
Http2 in practiceHttp2 in practice
Http2 in practice
 
Benchmarking distributed tracers
Benchmarking distributed tracersBenchmarking distributed tracers
Benchmarking distributed tracers
 
Peer Cache for Configuration Manager clients
Peer Cache for Configuration Manager clientsPeer Cache for Configuration Manager clients
Peer Cache for Configuration Manager clients
 
JDKIO: Java EE 8 what Servlet 4 and HTTP2 mean to you
JDKIO: Java EE 8 what Servlet 4 and HTTP2 mean to youJDKIO: Java EE 8 what Servlet 4 and HTTP2 mean to you
JDKIO: Java EE 8 what Servlet 4 and HTTP2 mean to you
 
Java EE 8: What Servlet 4.0 and HTTP2 mean to you
Java EE 8: What Servlet 4.0 and HTTP2 mean to youJava EE 8: What Servlet 4.0 and HTTP2 mean to you
Java EE 8: What Servlet 4.0 and HTTP2 mean to you
 
Implementing WebServices with Camel and CXF in ServiceMix
Implementing WebServices with Camel and CXF in ServiceMixImplementing WebServices with Camel and CXF in ServiceMix
Implementing WebServices with Camel and CXF in ServiceMix
 
Covert Timing Channels based on HTTP Cache Headers (Special Edition for Top 1...
Covert Timing Channels based on HTTP Cache Headers (Special Edition for Top 1...Covert Timing Channels based on HTTP Cache Headers (Special Edition for Top 1...
Covert Timing Channels based on HTTP Cache Headers (Special Edition for Top 1...
 
Servlet
ServletServlet
Servlet
 
Learning j meter in 60 minutes
Learning j meter in 60 minutesLearning j meter in 60 minutes
Learning j meter in 60 minutes
 
J meter introduction
J meter introductionJ meter introduction
J meter introduction
 

Similar to Async event based web server

Reactive programming
Reactive programmingReactive programming
Reactive programmingSUDIP GHOSH
 
(ATS4-PLAT08) Server Pool Management
(ATS4-PLAT08) Server Pool Management(ATS4-PLAT08) Server Pool Management
(ATS4-PLAT08) Server Pool ManagementBIOVIA
 
Reactive solutions using java 9 and spring reactor
Reactive solutions using java 9 and spring reactorReactive solutions using java 9 and spring reactor
Reactive solutions using java 9 and spring reactorOrenEzer1
 
Continuation_alan_20220503.pdf
Continuation_alan_20220503.pdfContinuation_alan_20220503.pdf
Continuation_alan_20220503.pdfShen yifeng
 
Scaling habits of ASP.NET
Scaling habits of ASP.NETScaling habits of ASP.NET
Scaling habits of ASP.NETDavid Giard
 
SharePoint Saturday The Conference 2011 - SP2010 Performance
SharePoint Saturday The Conference 2011 - SP2010 PerformanceSharePoint Saturday The Conference 2011 - SP2010 Performance
SharePoint Saturday The Conference 2011 - SP2010 PerformanceBrian Culver
 
Евгений Хыст "Application performance database related problems"
Евгений Хыст "Application performance database related problems"Евгений Хыст "Application performance database related problems"
Евгений Хыст "Application performance database related problems"Anna Shymchenko
 
Adding Real-time Features to PHP Applications
Adding Real-time Features to PHP ApplicationsAdding Real-time Features to PHP Applications
Adding Real-time Features to PHP ApplicationsRonny López
 
BITM3730 11-1.pptx
BITM3730 11-1.pptxBITM3730 11-1.pptx
BITM3730 11-1.pptxMattMarino13
 
servlets.ppt
servlets.pptservlets.ppt
servlets.pptEidTahir
 
Reverse ajax in 2014
Reverse ajax in 2014Reverse ajax in 2014
Reverse ajax in 2014Nenad Pecanac
 
Learn Advanced JAVA at ASIT
Learn Advanced JAVA at ASITLearn Advanced JAVA at ASIT
Learn Advanced JAVA at ASITASIT
 
Servlet and JSP
Servlet and JSPServlet and JSP
Servlet and JSPGary Yeh
 
BITM3730 Networking.pdf
BITM3730 Networking.pdfBITM3730 Networking.pdf
BITM3730 Networking.pdfMattMarino13
 
Tokyo AK Meetup Speedtest - Share.pdf
Tokyo AK Meetup Speedtest - Share.pdfTokyo AK Meetup Speedtest - Share.pdf
Tokyo AK Meetup Speedtest - Share.pdfssuser2ae721
 

Similar to Async event based web server (20)

Reactive programming
Reactive programmingReactive programming
Reactive programming
 
(ATS4-PLAT08) Server Pool Management
(ATS4-PLAT08) Server Pool Management(ATS4-PLAT08) Server Pool Management
(ATS4-PLAT08) Server Pool Management
 
Reactive solutions using java 9 and spring reactor
Reactive solutions using java 9 and spring reactorReactive solutions using java 9 and spring reactor
Reactive solutions using java 9 and spring reactor
 
Continuation_alan_20220503.pdf
Continuation_alan_20220503.pdfContinuation_alan_20220503.pdf
Continuation_alan_20220503.pdf
 
Scaling habits of ASP.NET
Scaling habits of ASP.NETScaling habits of ASP.NET
Scaling habits of ASP.NET
 
Fastest Servlets in the West
Fastest Servlets in the WestFastest Servlets in the West
Fastest Servlets in the West
 
SharePoint Saturday The Conference 2011 - SP2010 Performance
SharePoint Saturday The Conference 2011 - SP2010 PerformanceSharePoint Saturday The Conference 2011 - SP2010 Performance
SharePoint Saturday The Conference 2011 - SP2010 Performance
 
Евгений Хыст "Application performance database related problems"
Евгений Хыст "Application performance database related problems"Евгений Хыст "Application performance database related problems"
Евгений Хыст "Application performance database related problems"
 
Adding Real-time Features to PHP Applications
Adding Real-time Features to PHP ApplicationsAdding Real-time Features to PHP Applications
Adding Real-time Features to PHP Applications
 
BITM3730 11-1.pptx
BITM3730 11-1.pptxBITM3730 11-1.pptx
BITM3730 11-1.pptx
 
servlets.ppt
servlets.pptservlets.ppt
servlets.ppt
 
servlets.ppt
servlets.pptservlets.ppt
servlets.ppt
 
servlets.ppt
servlets.pptservlets.ppt
servlets.ppt
 
servlets.ppt
servlets.pptservlets.ppt
servlets.ppt
 
Reverse ajax in 2014
Reverse ajax in 2014Reverse ajax in 2014
Reverse ajax in 2014
 
Learn Advanced JAVA at ASIT
Learn Advanced JAVA at ASITLearn Advanced JAVA at ASIT
Learn Advanced JAVA at ASIT
 
Web Fendamentals
Web FendamentalsWeb Fendamentals
Web Fendamentals
 
Servlet and JSP
Servlet and JSPServlet and JSP
Servlet and JSP
 
BITM3730 Networking.pdf
BITM3730 Networking.pdfBITM3730 Networking.pdf
BITM3730 Networking.pdf
 
Tokyo AK Meetup Speedtest - Share.pdf
Tokyo AK Meetup Speedtest - Share.pdfTokyo AK Meetup Speedtest - Share.pdf
Tokyo AK Meetup Speedtest - Share.pdf
 

Recently uploaded

Explosives Industry manufacturing process.pdf
Explosives Industry manufacturing process.pdfExplosives Industry manufacturing process.pdf
Explosives Industry manufacturing process.pdf884710SadaqatAli
 
A CASE STUDY ON ONLINE TICKET BOOKING SYSTEM PROJECT.pdf
A CASE STUDY ON ONLINE TICKET BOOKING SYSTEM PROJECT.pdfA CASE STUDY ON ONLINE TICKET BOOKING SYSTEM PROJECT.pdf
A CASE STUDY ON ONLINE TICKET BOOKING SYSTEM PROJECT.pdfKamal Acharya
 
İTÜ CAD and Reverse Engineering Workshop
İTÜ CAD and Reverse Engineering WorkshopİTÜ CAD and Reverse Engineering Workshop
İTÜ CAD and Reverse Engineering WorkshopEmre Günaydın
 
power quality voltage fluctuation UNIT - I.pptx
power quality voltage fluctuation UNIT - I.pptxpower quality voltage fluctuation UNIT - I.pptx
power quality voltage fluctuation UNIT - I.pptxViniHema
 
Natalia Rutkowska - BIM School Course in Kraków
Natalia Rutkowska - BIM School Course in KrakówNatalia Rutkowska - BIM School Course in Kraków
Natalia Rutkowska - BIM School Course in Krakówbim.edu.pl
 
Top 13 Famous Civil Engineering Scientist
Top 13 Famous Civil Engineering ScientistTop 13 Famous Civil Engineering Scientist
Top 13 Famous Civil Engineering Scientistgettygaming1
 
ENERGY STORAGE DEVICES INTRODUCTION UNIT-I
ENERGY STORAGE DEVICES  INTRODUCTION UNIT-IENERGY STORAGE DEVICES  INTRODUCTION UNIT-I
ENERGY STORAGE DEVICES INTRODUCTION UNIT-IVigneshvaranMech
 
weather web application report.pdf
weather web application report.pdfweather web application report.pdf
weather web application report.pdfPratik Pawar
 
Introduction to Machine Learning Unit-5 Notes for II-II Mechanical Engineering
Introduction to Machine Learning Unit-5 Notes for II-II Mechanical EngineeringIntroduction to Machine Learning Unit-5 Notes for II-II Mechanical Engineering
Introduction to Machine Learning Unit-5 Notes for II-II Mechanical EngineeringC Sai Kiran
 
Introduction to Casting Processes in Manufacturing
Introduction to Casting Processes in ManufacturingIntroduction to Casting Processes in Manufacturing
Introduction to Casting Processes in Manufacturingssuser0811ec
 
Halogenation process of chemical process industries
Halogenation process of chemical process industriesHalogenation process of chemical process industries
Halogenation process of chemical process industriesMuhammadTufail242431
 
fundamentals of drawing and isometric and orthographic projection
fundamentals of drawing and isometric and orthographic projectionfundamentals of drawing and isometric and orthographic projection
fundamentals of drawing and isometric and orthographic projectionjeevanprasad8
 
Courier management system project report.pdf
Courier management system project report.pdfCourier management system project report.pdf
Courier management system project report.pdfKamal Acharya
 
shape functions of 1D and 2 D rectangular elements.pptx
shape functions of 1D and 2 D rectangular elements.pptxshape functions of 1D and 2 D rectangular elements.pptx
shape functions of 1D and 2 D rectangular elements.pptxVishalDeshpande27
 
Event Management System Vb Net Project Report.pdf
Event Management System Vb Net  Project Report.pdfEvent Management System Vb Net  Project Report.pdf
Event Management System Vb Net Project Report.pdfKamal Acharya
 
Online blood donation management system project.pdf
Online blood donation management system project.pdfOnline blood donation management system project.pdf
Online blood donation management system project.pdfKamal Acharya
 
ASME IX(9) 2007 Full Version .pdf
ASME IX(9)  2007 Full Version       .pdfASME IX(9)  2007 Full Version       .pdf
ASME IX(9) 2007 Full Version .pdfAhmedHussein950959
 
Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...
Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...
Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...Dr.Costas Sachpazis
 
RS Khurmi Machine Design Clutch and Brake Exercise Numerical Solutions
RS Khurmi Machine Design Clutch and Brake Exercise Numerical SolutionsRS Khurmi Machine Design Clutch and Brake Exercise Numerical Solutions
RS Khurmi Machine Design Clutch and Brake Exercise Numerical SolutionsAtif Razi
 

Recently uploaded (20)

Explosives Industry manufacturing process.pdf
Explosives Industry manufacturing process.pdfExplosives Industry manufacturing process.pdf
Explosives Industry manufacturing process.pdf
 
A CASE STUDY ON ONLINE TICKET BOOKING SYSTEM PROJECT.pdf
A CASE STUDY ON ONLINE TICKET BOOKING SYSTEM PROJECT.pdfA CASE STUDY ON ONLINE TICKET BOOKING SYSTEM PROJECT.pdf
A CASE STUDY ON ONLINE TICKET BOOKING SYSTEM PROJECT.pdf
 
İTÜ CAD and Reverse Engineering Workshop
İTÜ CAD and Reverse Engineering WorkshopİTÜ CAD and Reverse Engineering Workshop
İTÜ CAD and Reverse Engineering Workshop
 
power quality voltage fluctuation UNIT - I.pptx
power quality voltage fluctuation UNIT - I.pptxpower quality voltage fluctuation UNIT - I.pptx
power quality voltage fluctuation UNIT - I.pptx
 
Natalia Rutkowska - BIM School Course in Kraków
Natalia Rutkowska - BIM School Course in KrakówNatalia Rutkowska - BIM School Course in Kraków
Natalia Rutkowska - BIM School Course in Kraków
 
Top 13 Famous Civil Engineering Scientist
Top 13 Famous Civil Engineering ScientistTop 13 Famous Civil Engineering Scientist
Top 13 Famous Civil Engineering Scientist
 
ENERGY STORAGE DEVICES INTRODUCTION UNIT-I
ENERGY STORAGE DEVICES  INTRODUCTION UNIT-IENERGY STORAGE DEVICES  INTRODUCTION UNIT-I
ENERGY STORAGE DEVICES INTRODUCTION UNIT-I
 
weather web application report.pdf
weather web application report.pdfweather web application report.pdf
weather web application report.pdf
 
Introduction to Machine Learning Unit-5 Notes for II-II Mechanical Engineering
Introduction to Machine Learning Unit-5 Notes for II-II Mechanical EngineeringIntroduction to Machine Learning Unit-5 Notes for II-II Mechanical Engineering
Introduction to Machine Learning Unit-5 Notes for II-II Mechanical Engineering
 
Introduction to Casting Processes in Manufacturing
Introduction to Casting Processes in ManufacturingIntroduction to Casting Processes in Manufacturing
Introduction to Casting Processes in Manufacturing
 
Halogenation process of chemical process industries
Halogenation process of chemical process industriesHalogenation process of chemical process industries
Halogenation process of chemical process industries
 
fundamentals of drawing and isometric and orthographic projection
fundamentals of drawing and isometric and orthographic projectionfundamentals of drawing and isometric and orthographic projection
fundamentals of drawing and isometric and orthographic projection
 
Courier management system project report.pdf
Courier management system project report.pdfCourier management system project report.pdf
Courier management system project report.pdf
 
shape functions of 1D and 2 D rectangular elements.pptx
shape functions of 1D and 2 D rectangular elements.pptxshape functions of 1D and 2 D rectangular elements.pptx
shape functions of 1D and 2 D rectangular elements.pptx
 
Event Management System Vb Net Project Report.pdf
Event Management System Vb Net  Project Report.pdfEvent Management System Vb Net  Project Report.pdf
Event Management System Vb Net Project Report.pdf
 
Online blood donation management system project.pdf
Online blood donation management system project.pdfOnline blood donation management system project.pdf
Online blood donation management system project.pdf
 
ASME IX(9) 2007 Full Version .pdf
ASME IX(9)  2007 Full Version       .pdfASME IX(9)  2007 Full Version       .pdf
ASME IX(9) 2007 Full Version .pdf
 
Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...
Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...
Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...
 
RS Khurmi Machine Design Clutch and Brake Exercise Numerical Solutions
RS Khurmi Machine Design Clutch and Brake Exercise Numerical SolutionsRS Khurmi Machine Design Clutch and Brake Exercise Numerical Solutions
RS Khurmi Machine Design Clutch and Brake Exercise Numerical Solutions
 
Standard Reomte Control Interface - Neometrix
Standard Reomte Control Interface - NeometrixStandard Reomte Control Interface - Neometrix
Standard Reomte Control Interface - Neometrix
 

Async event based web server

  • 1. Event loop 를 이용한 웹 엔진 개발 17.6.16. 최종발표 F조 이기웅, 유종민, 김수
  • 2. 2 Results & Demo 1. Background 2. Goal 3. Diagram 3. Issue 4. Demo
  • 3. 3 Background Two Types of Web Server Multi-Threaded Server Single-Threaded Server
  • 4. Background Multi-Threaded Server Shortcomings • Spawn a new thread for every new http requests • Overhead of creating a new thread for every requests with simultaneous users access • Memory allocation with threads • Overhead with context switching • In I/O intensive scenarios the requests spend most of the time waiting for I/O to complete Multi-Threaded Server Shortcomings
  • 5. Background Single Thread Server : Alternative of Multi-Thread Server Single-Threaded Server • Asynchronous event driven IO which uses thread pool for IO task handling • Events made from http requests is dealt by Handler/Listener with callback • Application not to pause or sleep, but to become available for other requests. • Suitable for implementing Web Server which has Intensive IO task with clients
  • 6. 6 Goal Goal • Implementing Web Server Engine which deals with several http requests Requirements with Stable/Fast Web Server Engine • Stability - Handle large amounts of simultaneous http requests without crashes • Performance - High Latency, Low Error Rates • Reliability - Prevent malicious/abnormal client access Subgoals • Implement event loop structure and communication capabilities between event loop/worker threads • Caching/Buffer to improve performance with IO • Prevent malicious client access with two representative cases • Performance comparison with existing web server engines
  • 8. 8 Diagram 서버 주요 모듈 - Selector + Event Loop Selector - Select Initialization with opening socket to communicate with clients and registering server to selector waiting for requests from clients Selector - Accept/Read/Write Selector periodically checking requests from clients, register clients to selector and handle request as an event in event loop Ready Key(Selected Key) Selected key retrieved from selector, which is an event transformed from client request
  • 9. 9 Diagram 서버 주요 모듈 - HttpParser + Request Processor HttpParser - parseRequest Http content from a client is parsed into hash table, returning status of http request Request Processor - process If status is 200, keep handling the process.Otherwise make a
 http response with error code to the client Error Code 304 - Not Modified 400 - Bad Request 404 - Not Found 500 - Interval Server Error
  • 10. 10 Diagram 서버 주요 모듈 - Event Loop Request Processor - process With http request status 200, if task is light-weight overload handle the task in event loop. Otherwise, handle task with
 additional async thread Main Controller - writer With light-weight overload task after handling it in process, make a http response to client In a format of http message
  • 11. 11 Diagram 서버 주요 모듈 - I/O Thread + Thread Pool + Mem Cache I/O Thread - handle From the thread pool, allocate file IO task to waiting thread by calling submit function I/O Thread - loadFile Following the filePath, read the file from memory cache if exists. Otherwise read file from disk. MainController - writer Make a http response to client in a format of http message
  • 12. 12 Issues Web Cache Replacement Policy에 따른 Performance Optimization Problem Latency inefficiency with file I/O task handling Solution Find an optimal replacement policy for web cache, and apply it to memory cache of web server 1.FIFO(First In First Out) 2. LRU(Least Recently Used) 3. LFU(Least Frequently Used)
  • 13. 13 Issues Web Cache Optimization - Zipf distribution Zipf Distribution - A few elements that score very high (the left tail in the diagrams) - A medium number of elements with middle-of-the-road scores (The middle part of the diagram) - A huge number of elements that score very low (The right part of the diagram) * LRU Suitable than LFU
  • 14. 14 Issues Web Cache optimization - Test with LFU/LRU • LFU - 1,000 Simultaneous clients requests • LRU - 1,000 Simultaneous clients requests There was not much difference between LFU and LRU Policy => Adopted LRU on caching eviction 14
  • 15. 15 Issues ByteBuffer Optimization - Kernel Buffer/Heap Buffer Problem Reading http request message from clients and writing http response to client, It is essential to read/write message in a byte buffer. Consuming lots of times, it becomes one of the reason for delayed latency. Solution While considering pros and cons among kernel buffer and heap buffer, apply one with better performance to obtain optimization. 1.Kernel Buffer 2. Heap Buffer
  • 16. 16 Issues ByteBuffer Optimization - Kernel Buffer/Heap Buffer Kernel Buffer Heap Buffer Definition Contents of direct buffers reside outside of the normal garbage- collected heap Within JVM, memory where objects are stored Pros Faster to read/write on memory for filling With bytes and integers Allocation and deallocation is less expensive. GC enabled Cons Allocation and deallocation is more expensive Slower than kernel buffer due to GC functionality
  • 17. 17 Issues ByteBuffer Optimization - Kernel Buffer/Heap Buffer
  • 18. 18 Issues ByteBuffer Optimization - Kernel Buffer/Heap Buffer • Heap Buffer - 1,000 Simultaneous clients requests • Kernel Buffer - 1,000 Simultaneous clients requests Kernel Buffer outperforms Heap buffer in aspects of error rate and throughput. => Adopted kernel buffer by allocateDirect during initialization of program
  • 19. 19 Issues Reliability - Malicious/Abnormal Client Request Problem Web server confronts various malicious programs/scripts from hackers, at the same time abnormal client requests. This leads to server crash, so it needs to be prevented. Problem 1 - Request timeout. Problem 2 - Request too long. Solution Due to the fact that there are numerous kinds of malicious attacks/abnormal requests, prevent two representative cases by reflecting proper handling logics into the code. Solution 1 - Register request timeout limit on http request, return 408 error Solution 2 - Limit buffer size read from client http request, return 400 error
  • 20. 20 Issues Reliability - Malicious/Abnormal Client Request • Request timeout • Request too long Find request timeout problem and return 408 Request timeout Find request too long problem and return 400 Bad Request
  • 21. 21 Issues Simultaneous multi-client request optimization - Backlog Problem Java 기반의 시스템은 메모리를 JVM(Java Virtual Machine)에서 관리하기 때문에 Full GC 발생으로 인한 STW(Stop The World) 현상에서 자유로울 수 없다. 또한 Full GC 발생 시의 휴지기가 1초에서 4초 이상으로 급격하게 늘어, 시스템이 한 동안 먹통이 되면 모든 요청에 대해 응답할 수 없는 상태에 빠지게 된다. Solution Backlog는 미연결 연결들에 대한 큐의 늘어날 수 있는 최대 길이를 정의한다. 전체 시스템 메모리와 Asynchronous Web Server가 차지하는 Heap의 크기 및 Client당 메모리 점유에 대한 계산을 통해 적절한 Backlog와의 설정이 필요하다. 따라서 Backlog양을 50부터 200까지 10씩 늘려가며 profiling한 결과 최적의 결과값을 보여주는 150으로 설정하였다.
  • 22. 22 Issues Simultaneous multi-client request optimization - Backlog • Backlog 50 • Backlog 150 Backlog of 150 outperforms backlog of 50 in aspects of error rate and throughput. => Adopted backlog 150 in server socket binding
  • 23. 23 Live Demo - Open Browser and apply web server engine onto it Live Demo
  • 24. 24 Performance Measure With JMeter • NodeJS 및 타 비동기 웹 서버와의 비교 기준 • Test Plan #1 : 동시접속자 100명이 1MB 이하 의 File I/O를 총 1000번 정도의 Request • Criteria : Average Throughput, Average Response Time, Error Rate • Test Plan #2 : 동시접속자 1000명이 1MB 이 하의 File I/O를 총 10000번 정도의 Request • Criteria : Test Plan #1와 동일
  • 25. 25 Live Demo - JMeter Test Live Demo
  • 26. 26 Division and Assignment of Work • 김수 - 개발 환경 구축 및 Github 초기 연동 작업 - Http Parser 및 File IO Thread 구현 - Http 프로그래밍 관련 주요 이슈 담당 - 전체 문서 관리 - Caching(LFU/LRU/FIFO) 구현 및 테스트 담당 - Event Loop와 Thread Pool 통신 기능 구현 - JMeter에 의한 테스트셋 구현 및 성능 향상 담당 - 일정 조정 및 커뮤니케이션 담당 - Event Loop 구현 담당 - 소켓 프로그래밍 관련 주요 이슈 담당 • 유종민 • 이기웅
  • 27. 27 Schedule 프로젝트 시작 교수님 면담 3/3 담당자 미팅 3차 구현 완료 스펙 발표 3/31 최종 발표 6/16 2차 구현 완료 1차 구현 완료 6/16 담당자 미팅 3/10 6/9 교수님 면담 3/17 셀렉터 공부 3/16 최적화 진행 중간 발표 5/19 로직 설계 4/3
  • 28. End of Document 감사합니다. F 조 김수, 유종민, 이기웅 010.9553.2500. wooong1225@gmail.com