Why Scaling "Code" Is A Mistake


Laravel or Symfony? Who cares, USE BOTH!!

Whenever I talk about scaling, someone always wants to know the "tricks" to make their code faster..

"Like, can't I just change all of the double-quotes to single-quotes? I heard they're faster"

Arghhhhh NOOOOOO!!!!

That's not how anyone scales. It's like the "pick up lines" or the "quick-fix pills" of the scaling world..

In fact, scaling your CODE usually doesn't even matter.

Let me repeat that for emphasis. Scaling your CODE doesn't usually matter.

That's right… use all of the ORMs and Frameworks you want.. Laravel or Symfony? Who cares, USE BOTH!

Jokes aside.. besides sanity-checking your algorithms, scaling your code is a dirty, nearly useless pre-mature optimization.

Think about it.. PHP is a garbage collected, fully interpreted, slowish C-runtime glue. There isn't much opportunity to actually squeeze more performance out (okay Mr. 17 nested foreach loops, yes, I'm not counting you.. you can optimize that)

So if the answer ISN'T changing double quotes to single, or using array_key_exists() instead of isset().. how do we scale?

Well young scaler, we scale our INFRASTRUCTURE (and our database queries)

Scaling your PHP infrastructure

Even as a PHP programmer, you NEED to understand your stack, all the way down to the metal— the software behind the curtain.. Nginx, MySQL, PHP-FPM, etc.

Recent additions to my Stack

If you've read my book, you know that I advocate HAProxy, Nginx, PHP-FPM 5.5, MySQL 5.6, and Redis/Resque.

I've recently added bitly's open-source NSQ to my stack instead of using Redis for everything. It's incredibly elegant and I've easily been able to send about 1b/messages per day through it.

NSQ is fantastic for message passing for a service-oriented architecture or even just plain analytics.

As I've moved to SOA for more-and-more projects, I've noticed a real need for distributed config management. I added etcd to my stack for this workload, but the jury is still out on if it'll make the final cut.

Get a free chapter from the book


Want to check out the book before buying? Just tell me where to send the entire first chapter— I'll let you check it out for free.

It's your choice, you can spend 2 years learning this stuff on your own, or I can guide you through it in a weekend.