SlideShare a Scribd company logo
1 of 17
Download to read offline
Introducing
wsgi_lineprof
Yusuke Miyazaki
2017-09-08
PyCon JP 2017
Yusuke Miyazaki @ymyzk
• Master’s course student of Kyoto University
• Programming languages / Type system
• Member of CAMPHOR- in Kyoto
• Community for student engineers and designers
• Intern of a start-up in Tokyo (Working Remotely)
• Uses Node.js (TypeScript & JavaScript) mainly
• We’re hiring!
Visit ymyzk.com for more details
Do you like building
web applications?

🙋🙋🙋
Do you like building

"fast"

web applications?

"""
Do you know
ISUCON?

🙋"🙋"
ISUCON = Iikanjini Speed Up Contest
• Team: 2 or 3 people
• Objective: Make the given web application faster
• Modify configuration of OS or middleware
• Add or replace middleware
• Rewrite applications…
• Rule: If a benchmark score (≈ number of requests) is high,
then you win!!
ISUCON = Iikanjini Speed Up Contest
• I participated in ISUCON in 2015 and 2016…
• But I lost in qualification rounds
• It is not easy to speed up existing applications
How can we speed
up applications?

🤔🤔🤔
— Robert C. Pike "Notes on Programming in C"
“Measure.  Don't tune for speed until you've
measured, and even then don't unless one
part of the code overwhelms the rest.”
How can we find
bottlenecks?
🤔🤔🤔
Use Profilers
• Python
• profile / cProfile
• timeit
• line_profiler
• memory_profiler
• WSGI
• Werkzurg
• linesman
They works well. But I want
more simple one for webapp

(especially for ISUCON)
I create a new profiler
for web applications

💪💪💪
🎉 wsgi_lineprof 🎉
wsgi_lineprof
• WSGI middleware
• Works well with WAFs: Django, Flask, Bottle…
• Easy to integrate with existing applications
without changing existing code of app.
• Provides line-by-line profiling
• Records every function call during a request
• Records the followings for every lines:
• Number of times the line was executed
• Amount of time spent to execute the line
How to use
# Assume that WSGI app is defined as "app"








server = make_server('127.0.0.1', 8000, app)

server.serve_forever()
# wsgi_lineprof
filters = [
FilenameFilter("main.py"),
TotalTimeSorter(),
]
app = LineProfilerMiddleware(app, filters=filters)
Demo
Conclusion
• wsgi_lineprof is a simple WSGI middleware for line-
by-line profiling
github.com/ymyzk/wsgi_lineprof
• Proposals, feedback, and PRs are welcome!
• Let’s participate in ISUCON using Python and win a
victory! 🏆🏆🏆
Thank you for Listening!!

More Related Content

What's hot

Documentation-driven development for Python web APIs v2
Documentation-driven development for Python web APIs v2Documentation-driven development for Python web APIs v2
Documentation-driven development for Python web APIs v2
José Haro Peralta
 

What's hot (20)

Pimp legacy PHP apps with Apigility - TrueNorthPHP 2014
Pimp legacy PHP apps with Apigility - TrueNorthPHP 2014Pimp legacy PHP apps with Apigility - TrueNorthPHP 2014
Pimp legacy PHP apps with Apigility - TrueNorthPHP 2014
 
Angular2 & Native Script GDG DevFest 2016
Angular2 & Native Script GDG DevFest 2016Angular2 & Native Script GDG DevFest 2016
Angular2 & Native Script GDG DevFest 2016
 
apidays LIVE New York 2021 - API tool chain for low budget programs by Paul K...
apidays LIVE New York 2021 - API tool chain for low budget programs by Paul K...apidays LIVE New York 2021 - API tool chain for low budget programs by Paul K...
apidays LIVE New York 2021 - API tool chain for low budget programs by Paul K...
 
apidays LIVE Paris 2021 - Using OpenAPI to configure your API Gateway by Ole ...
apidays LIVE Paris 2021 - Using OpenAPI to configure your API Gateway by Ole ...apidays LIVE Paris 2021 - Using OpenAPI to configure your API Gateway by Ole ...
apidays LIVE Paris 2021 - Using OpenAPI to configure your API Gateway by Ole ...
 
TypeScript
TypeScriptTypeScript
TypeScript
 
ng-conf NativeScript and Angular 2 Workshop
ng-conf NativeScript and Angular 2 Workshopng-conf NativeScript and Angular 2 Workshop
ng-conf NativeScript and Angular 2 Workshop
 
Swagger - make your API accessible
Swagger - make your API accessibleSwagger - make your API accessible
Swagger - make your API accessible
 
Full Stack Flutter Testing
Full Stack Flutter Testing Full Stack Flutter Testing
Full Stack Flutter Testing
 
PyCon TW 2018 - A Python Engineer Under Giant Umbrella (巨大保護傘下的 Python 碼農辛酸史)
PyCon TW 2018 - A Python Engineer Under Giant Umbrella (巨大保護傘下的 Python 碼農辛酸史) PyCon TW 2018 - A Python Engineer Under Giant Umbrella (巨大保護傘下的 Python 碼農辛酸史)
PyCon TW 2018 - A Python Engineer Under Giant Umbrella (巨大保護傘下的 Python 碼農辛酸史)
 
3.html configuration
3.html configuration3.html configuration
3.html configuration
 
Action! Development and Operations for Sticker Shop
Action! Development and  Operations for Sticker ShopAction! Development and  Operations for Sticker Shop
Action! Development and Operations for Sticker Shop
 
Understanding how to use Swagger and its tools
Understanding how to use Swagger and its toolsUnderstanding how to use Swagger and its tools
Understanding how to use Swagger and its tools
 
Swagger in the API Lifecycle
Swagger in the API LifecycleSwagger in the API Lifecycle
Swagger in the API Lifecycle
 
Documentation-driven development for Python web APIs v2
Documentation-driven development for Python web APIs v2Documentation-driven development for Python web APIs v2
Documentation-driven development for Python web APIs v2
 
Fastlane on Android 介紹
Fastlane on Android 介紹Fastlane on Android 介紹
Fastlane on Android 介紹
 
Android development at mercari 2015
Android development at mercari 2015Android development at mercari 2015
Android development at mercari 2015
 
API Conference 2021
API Conference 2021API Conference 2021
API Conference 2021
 
NativeScript Developer Day Keynote - Todd Anglin & Burke Holland
NativeScript Developer Day Keynote - Todd Anglin & Burke HollandNativeScript Developer Day Keynote - Todd Anglin & Burke Holland
NativeScript Developer Day Keynote - Todd Anglin & Burke Holland
 
Docker Containers - Talk Linux Day 2015
Docker Containers - Talk Linux Day 2015Docker Containers - Talk Linux Day 2015
Docker Containers - Talk Linux Day 2015
 
Nativescript with angular 2
Nativescript with angular 2Nativescript with angular 2
Nativescript with angular 2
 

Viewers also liked

Viewers also liked (12)

Pycon jp2017 20170908_ota
Pycon jp2017 20170908_otaPycon jp2017 20170908_ota
Pycon jp2017 20170908_ota
 
プロダクト開発してわかったDjangoの深〜いパーミッション管理の話 @ PyconJP2017
プロダクト開発してわかったDjangoの深〜いパーミッション管理の話 @ PyconJP2017プロダクト開発してわかったDjangoの深〜いパーミッション管理の話 @ PyconJP2017
プロダクト開発してわかったDjangoの深〜いパーミッション管理の話 @ PyconJP2017
 
Pythonとパッケージングと私
Pythonとパッケージングと私Pythonとパッケージングと私
Pythonとパッケージングと私
 
ドローンのフライトコントローラをPythonで制御してみた話
ドローンのフライトコントローラをPythonで制御してみた話ドローンのフライトコントローラをPythonで制御してみた話
ドローンのフライトコントローラをPythonで制御してみた話
 
Pythonが動く仕組み(の概要)
Pythonが動く仕組み(の概要)Pythonが動く仕組み(の概要)
Pythonが動く仕組み(の概要)
 
Djangoフレームワークのユーザーモデルと認証
Djangoフレームワークのユーザーモデルと認証Djangoフレームワークのユーザーモデルと認証
Djangoフレームワークのユーザーモデルと認証
 
PyCon JP 2017Yuta Kitagami
PyCon JP 2017Yuta KitagamiPyCon JP 2017Yuta Kitagami
PyCon JP 2017Yuta Kitagami
 
Python におけるドメイン駆動設計(戦術面)の勘どころ
Python におけるドメイン駆動設計(戦術面)の勘どころPython におけるドメイン駆動設計(戦術面)の勘どころ
Python におけるドメイン駆動設計(戦術面)の勘どころ
 
PyconJP2017 Kivyによるアプリケーション開発のすすめ
PyconJP2017 Kivyによるアプリケーション開発のすすめPyconJP2017 Kivyによるアプリケーション開発のすすめ
PyconJP2017 Kivyによるアプリケーション開発のすすめ
 
Pythonはどうやってlen関数で長さを手にいれているの?
Pythonはどうやってlen関数で長さを手にいれているの?Pythonはどうやってlen関数で長さを手にいれているの?
Pythonはどうやってlen関数で長さを手にいれているの?
 
Pycon2017
Pycon2017Pycon2017
Pycon2017
 
Pythonと機械学習によるWebセキュリティの自動化
Pythonと機械学習によるWebセキュリティの自動化Pythonと機械学習によるWebセキュリティの自動化
Pythonと機械学習によるWebセキュリティの自動化
 

Similar to Introducing wsgi_lineprof / PyCon JP 2017 LT

Progressive Enhancement using WSGI
Progressive Enhancement using WSGIProgressive Enhancement using WSGI
Progressive Enhancement using WSGI
Matthew Wilkes
 
DaZhangJM0203JM0203
DaZhangJM0203JM0203DaZhangJM0203JM0203
DaZhangJM0203JM0203
Da Zhang
 

Similar to Introducing wsgi_lineprof / PyCon JP 2017 LT (20)

O365Con18 - Automate your Tasks through Azure Functions - Elio Struyf
O365Con18 - Automate your Tasks through Azure Functions - Elio StruyfO365Con18 - Automate your Tasks through Azure Functions - Elio Struyf
O365Con18 - Automate your Tasks through Azure Functions - Elio Struyf
 
[Struyf] Automate Your Tasks With Azure Functions
[Struyf] Automate Your Tasks With Azure Functions[Struyf] Automate Your Tasks With Azure Functions
[Struyf] Automate Your Tasks With Azure Functions
 
Service worker API
Service worker APIService worker API
Service worker API
 
Java 8 - Gateway Drug or End of Line?
Java 8 - Gateway Drug or End of Line?Java 8 - Gateway Drug or End of Line?
Java 8 - Gateway Drug or End of Line?
 
Building front-end apps that Scale - FOSDEM 2014
Building front-end apps that Scale - FOSDEM 2014Building front-end apps that Scale - FOSDEM 2014
Building front-end apps that Scale - FOSDEM 2014
 
MEAN Stack Warm-up
MEAN Stack Warm-upMEAN Stack Warm-up
MEAN Stack Warm-up
 
Progressive Enhancement using WSGI
Progressive Enhancement using WSGIProgressive Enhancement using WSGI
Progressive Enhancement using WSGI
 
Django course
Django courseDjango course
Django course
 
Cross Platform Angular 2 and TypeScript Development
Cross Platform Angular 2 and TypeScript DevelopmentCross Platform Angular 2 and TypeScript Development
Cross Platform Angular 2 and TypeScript Development
 
Resume
ResumeResume
Resume
 
Swagger - Making REST APIs friendlier
Swagger - Making REST APIs friendlierSwagger - Making REST APIs friendlier
Swagger - Making REST APIs friendlier
 
Azure tales: a real world CQRS and ES Deep Dive - Andrea Saltarello
Azure tales: a real world CQRS and ES Deep Dive - Andrea SaltarelloAzure tales: a real world CQRS and ES Deep Dive - Andrea Saltarello
Azure tales: a real world CQRS and ES Deep Dive - Andrea Saltarello
 
DevOps: Automate all the things
DevOps: Automate all the thingsDevOps: Automate all the things
DevOps: Automate all the things
 
Fed London - January 2015
Fed London - January 2015Fed London - January 2015
Fed London - January 2015
 
DaZhangJM0203JM0203
DaZhangJM0203JM0203DaZhangJM0203JM0203
DaZhangJM0203JM0203
 
Optimus XPages: An Explosion of Techniques and Best Practices
Optimus XPages: An Explosion of Techniques and Best PracticesOptimus XPages: An Explosion of Techniques and Best Practices
Optimus XPages: An Explosion of Techniques and Best Practices
 
AngularJS - Architecture decisions in a large project 
AngularJS - Architecture decisionsin a large project AngularJS - Architecture decisionsin a large project 
AngularJS - Architecture decisions in a large project 
 
_Python Ireland Meetup - Serverless ML - Dowling.pdf
_Python Ireland Meetup - Serverless ML - Dowling.pdf_Python Ireland Meetup - Serverless ML - Dowling.pdf
_Python Ireland Meetup - Serverless ML - Dowling.pdf
 
CI/CD: Lessons from LinkedIn and Mockito
CI/CD: Lessons from LinkedIn and MockitoCI/CD: Lessons from LinkedIn and Mockito
CI/CD: Lessons from LinkedIn and Mockito
 
BelTech 2017 - Building Quality in the Browser
BelTech 2017 - Building Quality in the BrowserBelTech 2017 - Building Quality in the Browser
BelTech 2017 - Building Quality in the Browser
 

More from Yusuke Miyazaki

More from Yusuke Miyazaki (12)

Dynamic Type Inference for Gradual Hindley–Milner Typing
Dynamic Type Inference for Gradual Hindley–Milner TypingDynamic Type Inference for Gradual Hindley–Milner Typing
Dynamic Type Inference for Gradual Hindley–Milner Typing
 
Python と Docker で mypy Playground を開発した話
Python と Docker で mypy Playground を開発した話Python と Docker で mypy Playground を開発した話
Python と Docker で mypy Playground を開発した話
 
オープンソースソフトウェア入門
オープンソースソフトウェア入門オープンソースソフトウェア入門
オープンソースソフトウェア入門
 
型ヒントについて考えよう!
型ヒントについて考えよう!型ヒントについて考えよう!
型ヒントについて考えよう!
 
iot.ymyzk.com の紹介
iot.ymyzk.com の紹介iot.ymyzk.com の紹介
iot.ymyzk.com の紹介
 
Django から各種チャットツールに通知するライブラリを作った話
Django から各種チャットツールに通知するライブラリを作った話Django から各種チャットツールに通知するライブラリを作った話
Django から各種チャットツールに通知するライブラリを作った話
 
iOS 開発のいま (ADF2015 LT会)
iOS 開発のいま (ADF2015 LT会)iOS 開発のいま (ADF2015 LT会)
iOS 開発のいま (ADF2015 LT会)
 
iOS 開発のいま (CAMPHOR- x KMC 合同LT会)
iOS 開発のいま (CAMPHOR- x KMC 合同LT会)iOS 開発のいま (CAMPHOR- x KMC 合同LT会)
iOS 開発のいま (CAMPHOR- x KMC 合同LT会)
 
Swift の問題点
Swift の問題点Swift の問題点
Swift の問題点
 
最新の iOS に対応したアプリの開発
最新の iOS に対応したアプリの開発最新の iOS に対応したアプリの開発
最新の iOS に対応したアプリの開発
 
コンピューターネットワーク入門
コンピューターネットワーク入門コンピューターネットワーク入門
コンピューターネットワーク入門
 
HTML初心者講座
HTML初心者講座HTML初心者講座
HTML初心者講座
 

Recently uploaded

CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
Health
 
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
anilsa9823
 

Recently uploaded (20)

Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Models
 
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptx
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
 
Microsoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdfMicrosoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdf
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
 
Diamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionDiamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with Precision
 
How To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsHow To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.js
 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview Questions
 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docx
 
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.com
 

Introducing wsgi_lineprof / PyCon JP 2017 LT

  • 2. Yusuke Miyazaki @ymyzk • Master’s course student of Kyoto University • Programming languages / Type system • Member of CAMPHOR- in Kyoto • Community for student engineers and designers • Intern of a start-up in Tokyo (Working Remotely) • Uses Node.js (TypeScript & JavaScript) mainly • We’re hiring! Visit ymyzk.com for more details
  • 3. Do you like building web applications?
 🙋🙋🙋
  • 4. Do you like building
 "fast"
 web applications?
 """
  • 6. ISUCON = Iikanjini Speed Up Contest • Team: 2 or 3 people • Objective: Make the given web application faster • Modify configuration of OS or middleware • Add or replace middleware • Rewrite applications… • Rule: If a benchmark score (≈ number of requests) is high, then you win!!
  • 7. ISUCON = Iikanjini Speed Up Contest • I participated in ISUCON in 2015 and 2016… • But I lost in qualification rounds • It is not easy to speed up existing applications
  • 8. How can we speed up applications?
 🤔🤔🤔
  • 9. — Robert C. Pike "Notes on Programming in C" “Measure.  Don't tune for speed until you've measured, and even then don't unless one part of the code overwhelms the rest.”
  • 10. How can we find bottlenecks? 🤔🤔🤔
  • 11. Use Profilers • Python • profile / cProfile • timeit • line_profiler • memory_profiler • WSGI • Werkzurg • linesman They works well. But I want more simple one for webapp
 (especially for ISUCON)
  • 12. I create a new profiler for web applications
 💪💪💪
  • 14. wsgi_lineprof • WSGI middleware • Works well with WAFs: Django, Flask, Bottle… • Easy to integrate with existing applications without changing existing code of app. • Provides line-by-line profiling • Records every function call during a request • Records the followings for every lines: • Number of times the line was executed • Amount of time spent to execute the line
  • 15. How to use # Assume that WSGI app is defined as "app" 
 
 
 
 server = make_server('127.0.0.1', 8000, app)
 server.serve_forever() # wsgi_lineprof filters = [ FilenameFilter("main.py"), TotalTimeSorter(), ] app = LineProfilerMiddleware(app, filters=filters)
  • 16. Demo
  • 17. Conclusion • wsgi_lineprof is a simple WSGI middleware for line- by-line profiling github.com/ymyzk/wsgi_lineprof • Proposals, feedback, and PRs are welcome! • Let’s participate in ISUCON using Python and win a victory! 🏆🏆🏆 Thank you for Listening!!