SlideShare a Scribd company logo
1 of 46
Download to read offline
Arnaud Bouchez - Synopse
Frameworks
Tuning
Arnaud Bouchez
• Open Source Founder
mORMot 2
SynPDF, dmustache
• Modern Delphi and FPC
DDD, SOA, ORM, MVC
Performance, SOLID
• Synopse
https://synopse.info
Arnaud Bouchez
dev @ https://tranquil.it/wapt
SW deployment Windows updates
IT Inventory
Arnaud Bouchez
dev @ https://tranquil.it/wapt
+7000 +400 +1 300 000
sw packages customers pc equipped
Frameworks Tuning
Frameworks Tuning
not expressiveness (yesterday)
not exhaustive
not Delphi centric
Languages & Frameworks
Performance Bottlenecks
• The Web Server
• The Database layer
• The threading/execution Model
• The RTL (JSON, heap…)
Disclaimer:
slide borrowed from yesterday’s session
Menu du jour
• The TFB Challenge
• Async Web Server
• Async Database Access
• JSON, RTTI, Mustache
The TFB Challenge
https://www.techempower.com/benchmarks
The TFB Challenge
The TFB Challenge
Web Frameworks Benchmarks
• Since 2013, a collaborative project
• Now one official round per year
• Hundredths of frameworks tested
• Seven web /endpoints tested
• 24/7 continuous tests on dedicated HW
The TFB Challenge
One official round per year
• Round 22 is just finished
• mORMot is #12 over 301 frameworks !
(with current weighting)
The TFB Challenge
Hundredths of frameworks tested
The TFB Challenge
Seven web /endpoints tested
/plaintext
/json
/db
/query?queries=###
/cached_queries?count=###
/update?queries=###
/fortunes
The TFB Challenge
Seven web /endpoints tested
• Reproduce on my dev laptop
• Compiled on Linux with Lazarus
• Run locally on the very same machine
The TFB Challenge
Gimme Numbers: Requests Per Sec
The TFB Challenge
endpoint rps% vs #1
/plaintext 99.4%
/json 91.8%
/db 59.7%
/query?queries=### 89.7%
/cached_queries?count=### 99.8%
/update?queries=### 81.5%
/fortunes 59.5%
The TFB Challenge
endpoint rps% vs #1
/plaintext 99.4%
/json 91.8%
/db single SELECT potential 59.7%
/query?queries=### 89.7%
/cached_queries?count=### 99.8%
/update?queries=### 81.5%
/fortunes 59.5%
The TFB Challenge
24/7 continuous tests on big HW
Latest runs are available at
https://tfb-status.techempower.com
The TFB Challenge
24/7 continuous tests on big HW
• Several strategies to fill all CPU cores
pin to CPU, several bound servers, threads
• Several strategies for database access
ORM, direct, async
• A lot of test & trials
guessing is usually wrong
no definitive/logical rules
The TFB Challenge
Demanding but not realistic
• Measured with wrk over a single endpoint
• Such perfect/optimal network does not exist
• Very small dataset
• No long-running tests
• No memory consumption
Async Web Server
Async Web Server
Several Web Servers
• THttpServer
1 thread per HTTP/1.1 client
thread pool for HTTP/1.0 requests (proxy)
• THttpApiServer
Windows-specific – using http.sys API
• THttpAsyncServer
thread pool for all requests
Async Web Server
Several WebSockets Servers
• TWebSocketServerRest
1 thread per WebSockets client
• THttpApiWebSocketServer
Windows-specific – using http.sys API
• TWebSocketAsyncServerRest
thread pool for all requests
Async Web Server
THttpAsyncServer
• Non-blocking read/write state machine
Using epoll API on Linux
• Based on abstract THttpAsyncConnections
HTTP-over-TCP per-connection architecture
• Optional TLS layer
with OpenSSL or Windows SSPI
and ACME/Let’s Encrypt built-in support
Async Web Server
THttpAsyncServer
• Can sustain thousands of concurrent clients
• With minimal memory/cpu consumption
• Exist as TWebSocketAsyncServerRest flavor
• THttpServer may be more reactive
for a few connections
Async Web Server
THttpAsyncServer
• Responses are computed in a thread pool
with regular blocking end-user code
• Optionally returned out-of-order
e.g. for asynchronous DB operations
• Only wake up threads if needed
to avoid syscalls on small queries
Async Web Server
THttpAsyncServer
• Avoid memory allocation
e.g. HTTP buffers reuse between connections
optional string interning of HTTP headers
• Non-blocking process
smallest possible granularity locks
Async Web Server
THttpAsyncServer
• Minimized syscalls
profiled with strace on Linux
 libc vDSO for clock_gettime()
 our own light locks with no mutex
 wakeup threads using eventfd() – only if needed
 per-second cache of date/time or timeout ticks
Async Web Server
THttpAsyncServer
• Minimized syscalls
profiled with strace on Linux
• Less optimized on Windows
Async Web Server
THttpAsyncServer
• Very efficient URI routing
with O(1) parsing of routes and parameters
• Can use the RTTI over methods
to define the endpoints
• Can redirect/rewrite URI before a REST layer
Async Web Server
THttpAsyncServer
• Perfect for the TFB use-case
top of /plaintext or /cached_queries
• Has been tuned to increase TFB numbers
also noticeable on other HW or OS
Async Web Server
mORMot 2 TFB Sample
https://github.com/synopse/mORMot2/tree/
master/ex/techempower-bench
Async Database Access
Async Database Access
PostgreSQL
• The Database of choice for TFB
• The Database of choice for most projects
Async Database Access
mormot.db.sql.postgres.pas
• Direct libpq client access
• Written from scratch
• Using mormot.db.sql.pas simplified design
cached statements with no TDataSet overhead
• Optional array binding
• Optional pipelined mode support
• Optional asynchronous / non-blocking API
Async Database Access
mORMot 2 TFB Sample
https://github.com/synopse/mORMot2/tree/
master/ex/techempower-bench
JSON, RTTI, Mustache
JSON, RTTI, Mustache
JSON
• mORMot is natively UTF-8 and JSON
on all platforms and compilers (even Delphi 7)
• mORMot 2 JSON core has been rewritten
for performance
JSON, RTTI, Mustache
Several JSON parsers
• SAX approach
• TDocVariant
• TOrmTableJson
• TDynArray
JSON, RTTI, Mustache
Several JSON parsers Delphi XE8, Win32
• SAX approach 725 MB/s
• TDocVariant 117 MB/s
• TOrmTableJson 496 MB/s
• TDynArray 332 MB/s
JSON, RTTI, Mustache
Several JSON parsers Delphi XE8, Win32
• SAX approach 725 MB/s
• TDocVariant 117 MB/s
• TOrmTableJson 496 MB/s
• TDynArray 332 MB/s
• Delphi JSON 6 MB/s
• JsonDataObjects 103 MB/s
• SuperObject 35 MB/s
• Grijjy 54 MB/s
• dwsJSON 97 MB/s
JSON, RTTI, Mustache
RTTI
• mORMot has its own RTTI cache
on all platforms and compilers
• mORMot 2 RTTI core has been rewritten
for performance and maintainability
(mORMot 1 did have duplicated logic)
JSON, RTTI, Mustache
Mustache
• mORMot has its own Mustache renderer
• mORMot 2 Mustache
can work directly on in-memory data
instead of TDocVariant containers
JSON, RTTI, Mustache
mORMot 2 TFB Sample
https://github.com/synopse/mORMot2/tree/
master/ex/techempower-bench
Frameworks Tuning
Questions? Wishes?
Opinions? Reactions?
No Marmots Were Harmed in the Making of This Session

More Related Content

Similar to EKON27-FrameworksTuning.pdf

Http - All you need to know
Http - All you need to knowHttp - All you need to know
Http - All you need to knowGökhan Şengün
 
A Tale of 2 Systems
A Tale of 2 SystemsA Tale of 2 Systems
A Tale of 2 SystemsDavid Newman
 
Balázs Bucsay - XFLTReaT: Building a Tunnel
Balázs Bucsay - XFLTReaT: Building a TunnelBalázs Bucsay - XFLTReaT: Building a Tunnel
Balázs Bucsay - XFLTReaT: Building a Tunnelhacktivity
 
Membase East Coast Meetups
Membase East Coast MeetupsMembase East Coast Meetups
Membase East Coast MeetupsMembase
 
«Scrapy internals» Александр Сибиряков, Scrapinghub
«Scrapy internals» Александр Сибиряков, Scrapinghub«Scrapy internals» Александр Сибиряков, Scrapinghub
«Scrapy internals» Александр Сибиряков, Scrapinghubit-people
 
(ATS4-PLAT01) Core Architecture Changes in AEP 9.0 and their Impact on Admini...
(ATS4-PLAT01) Core Architecture Changes in AEP 9.0 and their Impact on Admini...(ATS4-PLAT01) Core Architecture Changes in AEP 9.0 and their Impact on Admini...
(ATS4-PLAT01) Core Architecture Changes in AEP 9.0 and their Impact on Admini...BIOVIA
 
Comet: by pushing server data, we push the web forward
Comet: by pushing server data, we push the web forwardComet: by pushing server data, we push the web forward
Comet: by pushing server data, we push the web forwardNOLOH LLC.
 
Beyond 'Set it and Forget it': Proactively managing your EZproxy server
Beyond 'Set it and Forget it': Proactively managing your EZproxy serverBeyond 'Set it and Forget it': Proactively managing your EZproxy server
Beyond 'Set it and Forget it': Proactively managing your EZproxy serverNASIG
 
Fluentd at HKOScon
Fluentd at HKOSconFluentd at HKOScon
Fluentd at HKOSconN Masahiro
 
HTTP/2 Comes to Java: Servlet 4.0 and what it means for the Java/Jakarta EE e...
HTTP/2 Comes to Java: Servlet 4.0 and what it means for the Java/Jakarta EE e...HTTP/2 Comes to Java: Servlet 4.0 and what it means for the Java/Jakarta EE e...
HTTP/2 Comes to Java: Servlet 4.0 and what it means for the Java/Jakarta EE e...Edward Burns
 
Woo: Writing a fast web server @ ELS2015
Woo: Writing a fast web server @ ELS2015Woo: Writing a fast web server @ ELS2015
Woo: Writing a fast web server @ ELS2015fukamachi
 
XFLTReaT: a new dimension in tunnelling (BruCON 0x09 2017)
XFLTReaT: a new dimension in tunnelling (BruCON 0x09 2017)XFLTReaT: a new dimension in tunnelling (BruCON 0x09 2017)
XFLTReaT: a new dimension in tunnelling (BruCON 0x09 2017)Balazs Bucsay
 
Messaging, interoperability and log aggregation - a new framework
Messaging, interoperability and log aggregation - a new frameworkMessaging, interoperability and log aggregation - a new framework
Messaging, interoperability and log aggregation - a new frameworkTomas Doran
 
Parallel and Asynchronous Programming - ITProDevConnections 2012 (Greek)
Parallel and Asynchronous Programming -  ITProDevConnections 2012 (Greek)Parallel and Asynchronous Programming -  ITProDevConnections 2012 (Greek)
Parallel and Asynchronous Programming - ITProDevConnections 2012 (Greek)Panagiotis Kanavos
 
Trick or XFLTReaT a.k.a. Tunnel All The Things
Trick or XFLTReaT a.k.a. Tunnel All The ThingsTrick or XFLTReaT a.k.a. Tunnel All The Things
Trick or XFLTReaT a.k.a. Tunnel All The ThingsBalazs Bucsay
 

Similar to EKON27-FrameworksTuning.pdf (20)

Scalable Web Apps
Scalable Web AppsScalable Web Apps
Scalable Web Apps
 
Http - All you need to know
Http - All you need to knowHttp - All you need to know
Http - All you need to know
 
A Tale of 2 Systems
A Tale of 2 SystemsA Tale of 2 Systems
A Tale of 2 Systems
 
Balázs Bucsay - XFLTReaT: Building a Tunnel
Balázs Bucsay - XFLTReaT: Building a TunnelBalázs Bucsay - XFLTReaT: Building a Tunnel
Balázs Bucsay - XFLTReaT: Building a Tunnel
 
Http2 in practice
Http2 in practiceHttp2 in practice
Http2 in practice
 
Membase East Coast Meetups
Membase East Coast MeetupsMembase East Coast Meetups
Membase East Coast Meetups
 
«Scrapy internals» Александр Сибиряков, Scrapinghub
«Scrapy internals» Александр Сибиряков, Scrapinghub«Scrapy internals» Александр Сибиряков, Scrapinghub
«Scrapy internals» Александр Сибиряков, Scrapinghub
 
Follow the White Rabbit - Message Queues with PHP
Follow the White Rabbit - Message Queues with PHPFollow the White Rabbit - Message Queues with PHP
Follow the White Rabbit - Message Queues with PHP
 
(ATS4-PLAT01) Core Architecture Changes in AEP 9.0 and their Impact on Admini...
(ATS4-PLAT01) Core Architecture Changes in AEP 9.0 and their Impact on Admini...(ATS4-PLAT01) Core Architecture Changes in AEP 9.0 and their Impact on Admini...
(ATS4-PLAT01) Core Architecture Changes in AEP 9.0 and their Impact on Admini...
 
computer networking
computer networkingcomputer networking
computer networking
 
Comet: by pushing server data, we push the web forward
Comet: by pushing server data, we push the web forwardComet: by pushing server data, we push the web forward
Comet: by pushing server data, we push the web forward
 
Beyond 'Set it and Forget it': Proactively managing your EZproxy server
Beyond 'Set it and Forget it': Proactively managing your EZproxy serverBeyond 'Set it and Forget it': Proactively managing your EZproxy server
Beyond 'Set it and Forget it': Proactively managing your EZproxy server
 
Fluentd at HKOScon
Fluentd at HKOSconFluentd at HKOScon
Fluentd at HKOScon
 
Realtime web2012
Realtime web2012Realtime web2012
Realtime web2012
 
HTTP/2 Comes to Java: Servlet 4.0 and what it means for the Java/Jakarta EE e...
HTTP/2 Comes to Java: Servlet 4.0 and what it means for the Java/Jakarta EE e...HTTP/2 Comes to Java: Servlet 4.0 and what it means for the Java/Jakarta EE e...
HTTP/2 Comes to Java: Servlet 4.0 and what it means for the Java/Jakarta EE e...
 
Woo: Writing a fast web server @ ELS2015
Woo: Writing a fast web server @ ELS2015Woo: Writing a fast web server @ ELS2015
Woo: Writing a fast web server @ ELS2015
 
XFLTReaT: a new dimension in tunnelling (BruCON 0x09 2017)
XFLTReaT: a new dimension in tunnelling (BruCON 0x09 2017)XFLTReaT: a new dimension in tunnelling (BruCON 0x09 2017)
XFLTReaT: a new dimension in tunnelling (BruCON 0x09 2017)
 
Messaging, interoperability and log aggregation - a new framework
Messaging, interoperability and log aggregation - a new frameworkMessaging, interoperability and log aggregation - a new framework
Messaging, interoperability and log aggregation - a new framework
 
Parallel and Asynchronous Programming - ITProDevConnections 2012 (Greek)
Parallel and Asynchronous Programming -  ITProDevConnections 2012 (Greek)Parallel and Asynchronous Programming -  ITProDevConnections 2012 (Greek)
Parallel and Asynchronous Programming - ITProDevConnections 2012 (Greek)
 
Trick or XFLTReaT a.k.a. Tunnel All The Things
Trick or XFLTReaT a.k.a. Tunnel All The ThingsTrick or XFLTReaT a.k.a. Tunnel All The Things
Trick or XFLTReaT a.k.a. Tunnel All The Things
 

More from Arnaud Bouchez

EKON27-FrameworksExpressiveness.pdf
EKON27-FrameworksExpressiveness.pdfEKON27-FrameworksExpressiveness.pdf
EKON27-FrameworksExpressiveness.pdfArnaud Bouchez
 
Ekon25 mORMot 2 Server-Side Notifications
Ekon25 mORMot 2 Server-Side NotificationsEkon25 mORMot 2 Server-Side Notifications
Ekon25 mORMot 2 Server-Side NotificationsArnaud Bouchez
 
Ekon25 mORMot 2 Cryptography
Ekon25 mORMot 2 CryptographyEkon25 mORMot 2 Cryptography
Ekon25 mORMot 2 CryptographyArnaud Bouchez
 
Ekon24 from Delphi to AVX2
Ekon24 from Delphi to AVX2Ekon24 from Delphi to AVX2
Ekon24 from Delphi to AVX2Arnaud Bouchez
 
Ekon23 (2) Kingdom-Driven-Design applied to Social Media with mORMot
Ekon23 (2) Kingdom-Driven-Design applied to Social Media with mORMotEkon23 (2) Kingdom-Driven-Design applied to Social Media with mORMot
Ekon23 (2) Kingdom-Driven-Design applied to Social Media with mORMotArnaud Bouchez
 
Ekon23 (1) Kingdom-Driven-Design
Ekon23 (1) Kingdom-Driven-DesignEkon23 (1) Kingdom-Driven-Design
Ekon23 (1) Kingdom-Driven-DesignArnaud Bouchez
 
High Performance Object Pascal Code on Servers (at EKON 22)
High Performance Object Pascal Code on Servers (at EKON 22)High Performance Object Pascal Code on Servers (at EKON 22)
High Performance Object Pascal Code on Servers (at EKON 22)Arnaud Bouchez
 
Object Pascal Clean Code Guidelines Proposal (at EKON 22)
Object Pascal Clean Code Guidelines Proposal (at EKON 22)Object Pascal Clean Code Guidelines Proposal (at EKON 22)
Object Pascal Clean Code Guidelines Proposal (at EKON 22)Arnaud Bouchez
 
Ekon21 Microservices - SOLID Meets SOA
Ekon21 Microservices - SOLID Meets SOAEkon21 Microservices - SOLID Meets SOA
Ekon21 Microservices - SOLID Meets SOAArnaud Bouchez
 
Ekon21 Microservices - Event Driven Design
Ekon21 Microservices - Event Driven DesignEkon21 Microservices - Event Driven Design
Ekon21 Microservices - Event Driven DesignArnaud Bouchez
 
Ekon20 mORMot WorkShop Delphi
Ekon20 mORMot WorkShop DelphiEkon20 mORMot WorkShop Delphi
Ekon20 mORMot WorkShop DelphiArnaud Bouchez
 
Ekon20 mORMot SOA Delphi Conference
Ekon20 mORMot SOA Delphi Conference Ekon20 mORMot SOA Delphi Conference
Ekon20 mORMot SOA Delphi Conference Arnaud Bouchez
 
Ekon20 mORMot Legacy Code Technical Debt Delphi Conference
Ekon20 mORMot Legacy Code Technical Debt Delphi Conference Ekon20 mORMot Legacy Code Technical Debt Delphi Conference
Ekon20 mORMot Legacy Code Technical Debt Delphi Conference Arnaud Bouchez
 
D1 from interfaces to solid
D1 from interfaces to solidD1 from interfaces to solid
D1 from interfaces to solidArnaud Bouchez
 
D2 domain driven-design
D2 domain driven-designD2 domain driven-design
D2 domain driven-designArnaud Bouchez
 

More from Arnaud Bouchez (20)

EKON27-FrameworksExpressiveness.pdf
EKON27-FrameworksExpressiveness.pdfEKON27-FrameworksExpressiveness.pdf
EKON27-FrameworksExpressiveness.pdf
 
Ekon25 mORMot 2 Server-Side Notifications
Ekon25 mORMot 2 Server-Side NotificationsEkon25 mORMot 2 Server-Side Notifications
Ekon25 mORMot 2 Server-Side Notifications
 
Ekon25 mORMot 2 Cryptography
Ekon25 mORMot 2 CryptographyEkon25 mORMot 2 Cryptography
Ekon25 mORMot 2 Cryptography
 
Ekon24 from Delphi to AVX2
Ekon24 from Delphi to AVX2Ekon24 from Delphi to AVX2
Ekon24 from Delphi to AVX2
 
Ekon24 mORMot 2
Ekon24 mORMot 2Ekon24 mORMot 2
Ekon24 mORMot 2
 
Ekon23 (2) Kingdom-Driven-Design applied to Social Media with mORMot
Ekon23 (2) Kingdom-Driven-Design applied to Social Media with mORMotEkon23 (2) Kingdom-Driven-Design applied to Social Media with mORMot
Ekon23 (2) Kingdom-Driven-Design applied to Social Media with mORMot
 
Ekon23 (1) Kingdom-Driven-Design
Ekon23 (1) Kingdom-Driven-DesignEkon23 (1) Kingdom-Driven-Design
Ekon23 (1) Kingdom-Driven-Design
 
High Performance Object Pascal Code on Servers (at EKON 22)
High Performance Object Pascal Code on Servers (at EKON 22)High Performance Object Pascal Code on Servers (at EKON 22)
High Performance Object Pascal Code on Servers (at EKON 22)
 
Object Pascal Clean Code Guidelines Proposal (at EKON 22)
Object Pascal Clean Code Guidelines Proposal (at EKON 22)Object Pascal Clean Code Guidelines Proposal (at EKON 22)
Object Pascal Clean Code Guidelines Proposal (at EKON 22)
 
Ekon21 Microservices - SOLID Meets SOA
Ekon21 Microservices - SOLID Meets SOAEkon21 Microservices - SOLID Meets SOA
Ekon21 Microservices - SOLID Meets SOA
 
Ekon21 Microservices - Event Driven Design
Ekon21 Microservices - Event Driven DesignEkon21 Microservices - Event Driven Design
Ekon21 Microservices - Event Driven Design
 
Ekon20 mORMot WorkShop Delphi
Ekon20 mORMot WorkShop DelphiEkon20 mORMot WorkShop Delphi
Ekon20 mORMot WorkShop Delphi
 
Ekon20 mORMot SOA Delphi Conference
Ekon20 mORMot SOA Delphi Conference Ekon20 mORMot SOA Delphi Conference
Ekon20 mORMot SOA Delphi Conference
 
Ekon20 mORMot Legacy Code Technical Debt Delphi Conference
Ekon20 mORMot Legacy Code Technical Debt Delphi Conference Ekon20 mORMot Legacy Code Technical Debt Delphi Conference
Ekon20 mORMot Legacy Code Technical Debt Delphi Conference
 
2016 mORMot
2016 mORMot2016 mORMot
2016 mORMot
 
A1 from n tier to soa
A1 from n tier to soaA1 from n tier to soa
A1 from n tier to soa
 
D1 from interfaces to solid
D1 from interfaces to solidD1 from interfaces to solid
D1 from interfaces to solid
 
A3 from sql to orm
A3 from sql to ormA3 from sql to orm
A3 from sql to orm
 
A2 from soap to rest
A2 from soap to restA2 from soap to rest
A2 from soap to rest
 
D2 domain driven-design
D2 domain driven-designD2 domain driven-design
D2 domain driven-design
 

Recently uploaded

EY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityEY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityNeo4j
 
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio, Inc.
 
Folding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a seriesFolding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a seriesPhilip Schwarz
 
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte GermanySuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte GermanyChristoph Pohl
 
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...Matt Ray
 
Unveiling the Future: Sylius 2.0 New Features
Unveiling the Future: Sylius 2.0 New FeaturesUnveiling the Future: Sylius 2.0 New Features
Unveiling the Future: Sylius 2.0 New FeaturesŁukasz Chruściel
 
MYjobs Presentation Django-based project
MYjobs Presentation Django-based projectMYjobs Presentation Django-based project
MYjobs Presentation Django-based projectAnoyGreter
 
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdfGOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdfAlina Yurenko
 
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...Angel Borroy López
 
英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作qr0udbr0
 
A healthy diet for your Java application Devoxx France.pdf
A healthy diet for your Java application Devoxx France.pdfA healthy diet for your Java application Devoxx France.pdf
A healthy diet for your Java application Devoxx France.pdfMarharyta Nedzelska
 
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...OnePlan Solutions
 
SpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at RuntimeSpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at Runtimeandrehoraa
 
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxKnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxTier1 app
 
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样umasea
 
Cloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEECloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEEVICTOR MAESTRE RAMIREZ
 
What are the key points to focus on before starting to learn ETL Development....
What are the key points to focus on before starting to learn ETL Development....What are the key points to focus on before starting to learn ETL Development....
What are the key points to focus on before starting to learn ETL Development....kzayra69
 
Buds n Tech IT Solutions: Top-Notch Web Services in Noida
Buds n Tech IT Solutions: Top-Notch Web Services in NoidaBuds n Tech IT Solutions: Top-Notch Web Services in Noida
Buds n Tech IT Solutions: Top-Notch Web Services in Noidabntitsolutionsrishis
 

Recently uploaded (20)

EY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityEY_Graph Database Powered Sustainability
EY_Graph Database Powered Sustainability
 
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
 
Folding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a seriesFolding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a series
 
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte GermanySuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
 
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
 
Hot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort Service
Hot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort ServiceHot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort Service
Hot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort Service
 
Unveiling the Future: Sylius 2.0 New Features
Unveiling the Future: Sylius 2.0 New FeaturesUnveiling the Future: Sylius 2.0 New Features
Unveiling the Future: Sylius 2.0 New Features
 
MYjobs Presentation Django-based project
MYjobs Presentation Django-based projectMYjobs Presentation Django-based project
MYjobs Presentation Django-based project
 
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdfGOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
 
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...
 
英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作
 
A healthy diet for your Java application Devoxx France.pdf
A healthy diet for your Java application Devoxx France.pdfA healthy diet for your Java application Devoxx France.pdf
A healthy diet for your Java application Devoxx France.pdf
 
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
 
SpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at RuntimeSpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at Runtime
 
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxKnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
 
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
 
Cloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEECloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEE
 
What are the key points to focus on before starting to learn ETL Development....
What are the key points to focus on before starting to learn ETL Development....What are the key points to focus on before starting to learn ETL Development....
What are the key points to focus on before starting to learn ETL Development....
 
2.pdf Ejercicios de programación competitiva
2.pdf Ejercicios de programación competitiva2.pdf Ejercicios de programación competitiva
2.pdf Ejercicios de programación competitiva
 
Buds n Tech IT Solutions: Top-Notch Web Services in Noida
Buds n Tech IT Solutions: Top-Notch Web Services in NoidaBuds n Tech IT Solutions: Top-Notch Web Services in Noida
Buds n Tech IT Solutions: Top-Notch Web Services in Noida
 

EKON27-FrameworksTuning.pdf

  • 1. Arnaud Bouchez - Synopse Frameworks Tuning
  • 2. Arnaud Bouchez • Open Source Founder mORMot 2 SynPDF, dmustache • Modern Delphi and FPC DDD, SOA, ORM, MVC Performance, SOLID • Synopse https://synopse.info
  • 3. Arnaud Bouchez dev @ https://tranquil.it/wapt SW deployment Windows updates IT Inventory
  • 4. Arnaud Bouchez dev @ https://tranquil.it/wapt +7000 +400 +1 300 000 sw packages customers pc equipped
  • 6. Frameworks Tuning not expressiveness (yesterday) not exhaustive not Delphi centric
  • 7. Languages & Frameworks Performance Bottlenecks • The Web Server • The Database layer • The threading/execution Model • The RTL (JSON, heap…) Disclaimer: slide borrowed from yesterday’s session
  • 8. Menu du jour • The TFB Challenge • Async Web Server • Async Database Access • JSON, RTTI, Mustache
  • 11. The TFB Challenge Web Frameworks Benchmarks • Since 2013, a collaborative project • Now one official round per year • Hundredths of frameworks tested • Seven web /endpoints tested • 24/7 continuous tests on dedicated HW
  • 12. The TFB Challenge One official round per year • Round 22 is just finished • mORMot is #12 over 301 frameworks ! (with current weighting)
  • 13. The TFB Challenge Hundredths of frameworks tested
  • 14. The TFB Challenge Seven web /endpoints tested /plaintext /json /db /query?queries=### /cached_queries?count=### /update?queries=### /fortunes
  • 15. The TFB Challenge Seven web /endpoints tested • Reproduce on my dev laptop • Compiled on Linux with Lazarus • Run locally on the very same machine
  • 16. The TFB Challenge Gimme Numbers: Requests Per Sec
  • 17. The TFB Challenge endpoint rps% vs #1 /plaintext 99.4% /json 91.8% /db 59.7% /query?queries=### 89.7% /cached_queries?count=### 99.8% /update?queries=### 81.5% /fortunes 59.5%
  • 18. The TFB Challenge endpoint rps% vs #1 /plaintext 99.4% /json 91.8% /db single SELECT potential 59.7% /query?queries=### 89.7% /cached_queries?count=### 99.8% /update?queries=### 81.5% /fortunes 59.5%
  • 19. The TFB Challenge 24/7 continuous tests on big HW Latest runs are available at https://tfb-status.techempower.com
  • 20. The TFB Challenge 24/7 continuous tests on big HW • Several strategies to fill all CPU cores pin to CPU, several bound servers, threads • Several strategies for database access ORM, direct, async • A lot of test & trials guessing is usually wrong no definitive/logical rules
  • 21. The TFB Challenge Demanding but not realistic • Measured with wrk over a single endpoint • Such perfect/optimal network does not exist • Very small dataset • No long-running tests • No memory consumption
  • 23. Async Web Server Several Web Servers • THttpServer 1 thread per HTTP/1.1 client thread pool for HTTP/1.0 requests (proxy) • THttpApiServer Windows-specific – using http.sys API • THttpAsyncServer thread pool for all requests
  • 24. Async Web Server Several WebSockets Servers • TWebSocketServerRest 1 thread per WebSockets client • THttpApiWebSocketServer Windows-specific – using http.sys API • TWebSocketAsyncServerRest thread pool for all requests
  • 25. Async Web Server THttpAsyncServer • Non-blocking read/write state machine Using epoll API on Linux • Based on abstract THttpAsyncConnections HTTP-over-TCP per-connection architecture • Optional TLS layer with OpenSSL or Windows SSPI and ACME/Let’s Encrypt built-in support
  • 26. Async Web Server THttpAsyncServer • Can sustain thousands of concurrent clients • With minimal memory/cpu consumption • Exist as TWebSocketAsyncServerRest flavor • THttpServer may be more reactive for a few connections
  • 27. Async Web Server THttpAsyncServer • Responses are computed in a thread pool with regular blocking end-user code • Optionally returned out-of-order e.g. for asynchronous DB operations • Only wake up threads if needed to avoid syscalls on small queries
  • 28. Async Web Server THttpAsyncServer • Avoid memory allocation e.g. HTTP buffers reuse between connections optional string interning of HTTP headers • Non-blocking process smallest possible granularity locks
  • 29. Async Web Server THttpAsyncServer • Minimized syscalls profiled with strace on Linux  libc vDSO for clock_gettime()  our own light locks with no mutex  wakeup threads using eventfd() – only if needed  per-second cache of date/time or timeout ticks
  • 30. Async Web Server THttpAsyncServer • Minimized syscalls profiled with strace on Linux • Less optimized on Windows
  • 31. Async Web Server THttpAsyncServer • Very efficient URI routing with O(1) parsing of routes and parameters • Can use the RTTI over methods to define the endpoints • Can redirect/rewrite URI before a REST layer
  • 32. Async Web Server THttpAsyncServer • Perfect for the TFB use-case top of /plaintext or /cached_queries • Has been tuned to increase TFB numbers also noticeable on other HW or OS
  • 33. Async Web Server mORMot 2 TFB Sample https://github.com/synopse/mORMot2/tree/ master/ex/techempower-bench
  • 35. Async Database Access PostgreSQL • The Database of choice for TFB • The Database of choice for most projects
  • 36. Async Database Access mormot.db.sql.postgres.pas • Direct libpq client access • Written from scratch • Using mormot.db.sql.pas simplified design cached statements with no TDataSet overhead • Optional array binding • Optional pipelined mode support • Optional asynchronous / non-blocking API
  • 37. Async Database Access mORMot 2 TFB Sample https://github.com/synopse/mORMot2/tree/ master/ex/techempower-bench
  • 39. JSON, RTTI, Mustache JSON • mORMot is natively UTF-8 and JSON on all platforms and compilers (even Delphi 7) • mORMot 2 JSON core has been rewritten for performance
  • 40. JSON, RTTI, Mustache Several JSON parsers • SAX approach • TDocVariant • TOrmTableJson • TDynArray
  • 41. JSON, RTTI, Mustache Several JSON parsers Delphi XE8, Win32 • SAX approach 725 MB/s • TDocVariant 117 MB/s • TOrmTableJson 496 MB/s • TDynArray 332 MB/s
  • 42. JSON, RTTI, Mustache Several JSON parsers Delphi XE8, Win32 • SAX approach 725 MB/s • TDocVariant 117 MB/s • TOrmTableJson 496 MB/s • TDynArray 332 MB/s • Delphi JSON 6 MB/s • JsonDataObjects 103 MB/s • SuperObject 35 MB/s • Grijjy 54 MB/s • dwsJSON 97 MB/s
  • 43. JSON, RTTI, Mustache RTTI • mORMot has its own RTTI cache on all platforms and compilers • mORMot 2 RTTI core has been rewritten for performance and maintainability (mORMot 1 did have duplicated logic)
  • 44. JSON, RTTI, Mustache Mustache • mORMot has its own Mustache renderer • mORMot 2 Mustache can work directly on in-memory data instead of TDocVariant containers
  • 45. JSON, RTTI, Mustache mORMot 2 TFB Sample https://github.com/synopse/mORMot2/tree/ master/ex/techempower-bench
  • 46. Frameworks Tuning Questions? Wishes? Opinions? Reactions? No Marmots Were Harmed in the Making of This Session