Optimizing PHP code to process 50,000 lines per second instead of 30
stitcher.io·1d·
Lazy Loading
Preview
Report Post

Processing 11 million rows in minutes instead of hours

Written on 2026-01-19

Around 5 years ago, I decided to drop all client-side analytics on this blog, and instead opt for server-side anonymous analytics. I had several reasons:

  • No more client-side overhead by removing JavaScript libraries
  • Actually respecting my audience’s privacy
  • More accurate metrics because around 50% of visitors block client-side trackers
  • Finally, it was a fun challenge for me

The architecture is pretty straight forward: there’s a long-running script on my server monitoring this blog’s access log. It filters out crawlers and bot traffic, and stores real traffic in a database table. Since I want to generate graphs with this data, I opted to use [event sourcing](https://stitcher.io/blog/what-event-sou…

Similar Posts

Loading similar posts...

Keyboard Shortcuts

Navigation
Next / previous item
j/k
Open post
oorEnter
Preview post
v
Post Actions
Love post
a
Like post
l
Dislike post
d
Undo reaction
u
Recommendations
Add interest / feed
Enter
Not interested
x
Go to
Home
gh
Interests
gi
Feeds
gf
Likes
gl
History
gy
Changelog
gc
Settings
gs
Browse
gb
Search
/
General
Show this help
?
Submit feedback
!
Close modal / unfocus
Esc

Press ? anytime to show this help