Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
PDX Python lightning talk
Search
Kevin McConnell
March 27, 2014
Programming
180
2
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
PDX Python lightning talk
Kevin McConnell
March 27, 2014
Other Decks in Programming
See All in Programming
What We Talk About When We Talk About XP
m_seki
2
670
速く作れる。その次は、速く確かめられる開発へ 〜AIネイティブ開発を支える、Shift Down〜 / Can build fast. Next, moving to development where we can verify fast.
rkaga
5
4.3k
TiDB Cloudのカスタムコントローラーによるオートスケール対応
takaidohigasi
0
130
iOSDC2026登壇資料.pdf
riofujimon
0
180
Augmenting AI with the Power of Jakarta EE
ivargrimstad
0
270
Vue Fes Japan 2026 タイムテーブル徹底解説
448jp
1
490
LoopHub - ローカルで動く GitHub で、AI と共同開発
jugyo
1
570
Snowflakeで業務アプリを作ろう。 Snowflakeのアプリ機能解説&実践ガイド
ayumu_yamaguchi
2
300
MVNOの申込からeSIM開通までをiOSアプリでつなぐ- 本人確認・MNP・通信事業者基盤をまたぐ実装
satotakeshi
0
460
App Intentsのビルドプロセスを支える技術
kntkymt
0
420
Streamlitで実現する自然言語データアプリ開発
ayumu_yamaguchi
1
310
AI × TiDD / 2026.09.05 Redmine 大阪
tokudiro
1
180
Featured
See All Featured
SEO Brein meetup: CTRL+C is not how to scale international SEO
lindahogenes
2
2.9k
How to train your dragon (web standard)
notwaldorf
97
6.8k
Kristin Tynski - Automating Marketing Tasks With AI
techseoconnect
PRO
0
520
Designing Experiences People Love
moore
143
24k
Design of three-dimensional binary manipulators for pick-and-place task avoiding obstacles (IECON2024)
konakalab
0
600
Building Flexible Design Systems
yeseniaperezcruz
330
41k
Rails Girls Zürich Keynote
gr2m
96
14k
[RailsConf 2023] Rails as a piece of cake
palkan
59
7k
Connecting the Dots Between Site Speed, User Experience & Your Business [WebExpo 2025]
tammyeverts
11
1k
Easily Structure & Communicate Ideas using Wireframe
afnizarnur
194
17k
Code Review Best Practice
trishagee
74
20k
Organizational Design Perspectives: An Ontology of Organizational Design Elements
kimpetersen
PRO
1
830
Transcript
None
Kevin McConnell @kevinmcconnell
A tiny thread pool class
A tiny thread pool class or The impact on performance
of a Service Oriented Architecture
A tiny thread pool class or The impact on performance
of a Service Oriented Architecture or That time we had that really slow website and we made it much faster with only about 10 lines of code
A typical web application • Is written using a framework
• Has some business logic • Talks to other systems • Databases • Caches • APIs
parsing business logic rendering time
parsing business logic rendering time Some of this time spent
waiting on other systems! (hopefully not too much)
time
time (╯°□°)╯︵ ┻━┻
Our application • Connects to ~6 internal APIs • ...most
of which are slow • Hardly any state of its own • Relatively simple business logic
parsing rendering time call API call API call API call
API business logic business logic business logic business logic
parsing business logic rendering time call API call API call
API call API
parsing business logic rendering time call API call API call
API call API ~500ms (mean)
parsing business logic rendering time call API call API call
API call API ~500ms (mean) (mostly just waiting! zzzzz.....)
parsing business logic rendering time call API call API call
API call API ~ 125ms
from threading import Thread! ! ! class ThreadQueue:! def __init__(self):!
self._tasks = {}! self._results = {}! ! def run(self, name, fn, *args, **kwargs):! thread = Thread(target=self._perform,! args=[name, fn, args, kwargs])! self._tasks[name] = thread! thread.start()! ! def get(self, name):! self._tasks[name].join()! return self._results[name]! ! def _perform(self, name, fn, args, kwargs):! self._results[name] = fn(*args, **kwargs)!
from threading import Thread! ! ! class ThreadQueue:! def __init__(self):!
self._tasks = {}! self._results = {}! ! def run(self, name, fn, *args, **kwargs):! thread = Thread(target=self._perform,! args=[name, fn, args, kwargs])! self._tasks[name] = thread! thread.start()! ! def get(self, name):! self._tasks[name].join()! return self._results[name]! ! def _perform(self, name, fn, args, kwargs):! self._results[name] = fn(*args, **kwargs)!
from threading import Thread! ! ! class ThreadQueue:! def __init__(self):!
self._tasks = {}! self._results = {}! ! def run(self, name, fn, *args, **kwargs):! thread = Thread(target=self._perform,! args=[name, fn, args, kwargs])! self._tasks[name] = thread! thread.start()! ! def get(self, name):! self._tasks[name].join()! return self._results[name]! ! def _perform(self, name, fn, args, kwargs):! self._results[name] = fn(*args, **kwargs)!
from threadqueue import ThreadQueue! ! tq = ThreadQueue()! ! tq.run('notifications',
get_user_notifications)! tq.run('billing', get_billing_status)! tq.run('privileges', get_user_privileges)! ! # ...things happen...! # ...! ! if tq.get('privileges')['can_create_projects']:! create_project(...)!
from threadqueue import ThreadQueue! ! tq = ThreadQueue()! ! tq.run('notifications',
get_user_notifications)! tq.run('billing', get_billing_status)! tq.run('privileges', get_user_privileges)! ! # ...things happen...! # ...! ! if tq.get('privileges')['can_create_projects']:! create_project(...)! returns! immediately
from threadqueue import ThreadQueue! ! tq = ThreadQueue()! ! tq.run('notifications',
get_user_notifications)! tq.run('billing', get_billing_status)! tq.run('privileges', get_user_privileges)! ! # ...things happen...! # ...! ! if tq.get('privileges')['can_create_projects']:! create_project(...)! returns! immediately blocks if! results! pending
What we learned • Apps that use many external services
can spend a lot of time blocked on I/O • One way to minimize the waiting time is to do all your waiting at once • There's great support for all sorts of nice concurrency models nowadays, but often a Thread is all you need
@kevinmcconnell Questions? Thanks!
None