How to make PHP apps scale

The most popular language for Web apps, PHP tends to buckle under heavy loads -- unless you opt for cloud scaling and a NoSQL back end

By Andrew Oliver, InfoWorld |  Software, PHP

The power of PHP and an RDBMS is the ability to nail the major features of an application with cheaply paid developers in a record amount of time. Unfortunately, the default runtime environment used by PHP is simply an unscalable mess.

A lot of the folks I've worked with do not care about maintainability; their PHP applications are throwaway, but heavily loaded and highly concurrent. For example, I worked with a company that developed a PHP marketing application with an Oracle back end, where you bought its products and could exchange your "points" for features of an online game. It worked great -- until it reached a few million users.

[ See InfoWorld's review of fabulous PHP frameworks and MongoDB's flexible, scalable take on NoSQL. | Follow the latest issues in software development with InfoWorld's Developer World newsletter. ]

The truth is that if you have enough servers and enough database servers, you don't have contention. But with a PHP Web app on top, an RDBMS like Oracle just can't be scaled cost-effectively to deliver both good read and write performance.

As it turns out, there's a modern solution to the problem: the cloud plus NoSQL. Cloud infrastructure gives us the ability to spin up enough servers, and a NoSQL database enables us to shard our data effectively. But first, let's examine why PHP's runtime environment is such dog to begin with.

Why PHP's runtime environment sucksThe most common runtime for PHP is the Apache Web Server in prefork mode, which means that the Web server runs a series of separate subprocesses to support concurrent requests. When you combine this concurrency characteristic with the use of a traditional relational database like MySQL, PostgreSQL, or Oracle, this choice implies unpooled database connections because database connection pooling requires a shared memory space.

Originally published on InfoWorld |  Click here to read the original story.
Join us:






SoftwareWhite Papers & Webcasts

Webcast On Demand

HP DevOps KnowledgeVault

Sponsor: HP

See more White Papers | Webcasts

Answers - Powered by ITworld

ITworld Answers helps you solve problems and share expertise. Ask a question or take a crack at answering the new questions below.

Ask a Question