Skip to content

Instantly share code, notes, and snippets.

Created May 15, 2024 10:00
Show Gist options
  • Save mmartinjoo/ec0b7f737a4dcd867a6e4d8faa05a07d to your computer and use it in GitHub Desktop.
Save mmartinjoo/ec0b7f737a4dcd867a6e4d8faa05a07d to your computer and use it in GitHub Desktop.
Performance with Laravel Table of Contents

Fundamentals - 217 pages (Basic Package)

Measuring performance

  • ab
  • jmeter
  • Inspector
  • Telescope
  • OpenTelemetry
  • XDebug + qcachegrind
  • Clockwork
  • htop
  • How to start measuring performance?

N+1 queries

  • Solutions
  • Prevent lazy loading
  • Let the client decide what it wants

Multiple resources


  • Cursor pagination

Database indexing

  • Theory Arrays
  • Linked list
  • Binary tree
  • Binary search tree (BST) Indexing in the early days
  • Single-level indexing
  • Multi-level indexing B-Tree
  • Problems with B-Trees B+ Trees
  • Index access types const
  • range
  • range (again) index
  • ALL
  • Select *
  • Composite indexes Cardinality
  • Database indexing in practice Listing posts by status Feed
  • Publishing posts
  • Avoiding memory problems Avoiding spamming the database Measuring performance

Async workflows

  • Web scraping with jobs Concurrent programming
  • Concurrent programming
  • fork
  • Concurrent HTTP requests Queues and workers
  • Queues and workers
  • supervisor
  • Multiple queues and priorities
  • Optimizing worker processes

Chunking large datasets

  • Exports
  • Imports
  • Generators & LazyCollections
  • PHP generators
  • Imports with generators
  • Imports with LazyCollections
  • Reading files
  • Deleting records


  • fpm processes
  • nginx cache
  • Caching static content
  • Caching fastcgi responses
  • MySQL slow query log
  • Monitoring database connections
  • Docker resource limits
  • Health check monitors

System design and architecture - 145 pages (Premium Package)

Building an analytics platform


  • v1
  • v2
  • v3
  • v4
  • v5

PageView service

Analytics service

  • Page views
  • Unique visitors
  • Most visited pages

Measuring performance


  • site_id index
  • visited_at and site_id composite index
  • site_id and visited_at composite index


Hashing URLs



Sorted sets

Page views

  • Querying page views
  • Daily and monthly page views
  • Scaling down the problem
  • Inserting page views
  • Time complexity

Unique visitors

  • Querying unique visitors
  • Daily and monthly unique visitors
  • HyperLogLog
  • Daily unique visitors
  • Monthly unique visitors
  • Hourly unique visitors
  • Scaling down the problem
  • Inserting unique visitors
  • Time complexity
  • Memoization

Most visited pages

  • Querying most visited pages
  • Scaling down the problem
  • Inserting most visited page views
  • Time complexity

Cleaning up data

Falling back to MySQL

Avoiding accidental data loss



Architecture v6: CQRS

  • The event stream
Copy link

This is going to be the ultimate performance book!

Copy link

This is going to be the ultimate performance book!

Thank you!

Copy link

My question to you is, how and where do gather the strength to do all these? Amazing!!


Copy link

Is there a waitlist email subscription for this? 🤤

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment