`
haohappy2
  • 浏览: 315593 次
  • 性别: Icon_minigender_1
  • 来自: 上海
社区版块
存档分类
最新评论

Scale PHP

 
阅读更多

RockThePost.com is a LAMP stack hosted on Ec2. We're preparing to be featured in an email which will be sent to ~1M investors... all at the same time. For our 2 person engineering department, that meant we had to do a quick sanity check to see just how many people we can support concurrently.

Our app uses PHP's Zend Framework 2. Our web servers are two m1.medium Ec2 machines with an ELB in front of them setup to split the load. On the backend, we're running a master/slave MySQL database configuration. Very typical for most of the small data shops I've worked at.

Here are my opinions and thoughts in random order.

  • Use PHP's APC feature. I don't understand why this isn't on by default but having APC enabled is really a requirement in order for a website to have a chance at performing well.

  • Put everything that's not a .php request on a CDN. No need to bog down your origin server with static file requests. Our deployer puts everything on S3 and we abs path everything to CloudFront. Disclaimer: CloudFront has had some issues lately and we've recently set the site to instead serve all static materials directly from S3 until the CloudFront issues are resolved.

  • Don't make connections to other servers in your PHP code, such as the database and memcache servers, unless it's mandatory and there's really NO other way to do what you're trying to do. I'd guess that the majority of PHP web apps out there use a MySQL database for the backend session management and a memcache pool for caching. Making connections to other servers during your execution flow is not efficient. It blocks, runs up the CPU, and tends to hold up the line, as it were. Instead, use the APC key/value store for storing data in PHP and Varnish for full page caching.

  • I repeat... Use Varnish. In all likelihood, most of the pages on your site do not change, or hardly ever change. Varnish is the Memcache/ModRewrite of web server caching. Putting Varnish on my web server made the single biggest difference to my web app when I was load testing it.

  • Use a c1.xlarge. The m1.medium has only 1 CPU to handle all of the requests. I found that upgrading to a c1.xlarge, which has 8 CPU's, really paid off. During my load test, I did an apt-get install nmon and then ran nmon and monitored the CPU. You can literally watch the server use all 8 of its cores to churn out pages.

Google Analytics shows us how many seconds an average user spends on an average page. Using this information, we ran some load tests with Siege and were able to extrapolate that with the above recommendations, we should be able to handle 30,000 users concurrently per web server on the "exterior" of the site. For "interior" pages which are PHP powered, we're expecting to see something more along the lines of 1,000 concurrent sessions per server. In advance of the email blast, we'll launch a bunch of c1.xlarges and then kill them off slowly as we get more comfortable with the actual load we're seeing on blast day.

Finally, we will do more work to make our code itself more scaleable... however, the code is only about 4 months old and this is the first time we've ever been challenged to actually make it scale.

About RockThePost.com

We help entrepreneurs raise money for a new venture. If you're thinking about crowdfunding your next venture, use coupon code "HACKERNEWS" for a 50% discount on any of our plans.

分享到:
评论

相关推荐

    Web-Scale PHP Database Connection Management

    oracle官方介绍在php中使用oracle 的ppt

    scalable-php-system:一组 docker 文件,用于设置可扩展的 php 基础架构

    可扩展的 PHP 基础架构 基于码头工人 里面是什么? 用于处理 PHP 的 作为首选的网络服务器 ...用于应用程序缓存todo clusterize ... $ fig scale php=5 #5 php nodes $ fig scale web=2 #2 nginx nodes

    利用ffmpeg解决php5.2,php5.3的视频转码,截屏问题【亲测有效】

    利用ffmpeg解决php5.2,php5.3的视频转码,截屏问题,

    docker-nginx-php-fpm:Docker +(Traefik +)Nginx + PHP-FPM =正确的方法

    docker-nginx-php-fpm Docker +(Traefik +)Nginx + PHP-FPM =正确的方法 跑步 docker-compose up --detach docker-compose exec ... --scale php-fpm=3 生产 docker build . --tag wandersonwhcr/hello

    Advanced PHP Programming.pdf.英文原版. PHP高级编程

    The rapid maturation of PHP has created a skeptical population of users from more traditional “enterprise” languages who question the readiness and ability of PHP to scale, as well as a large ...

    处理特大数字的PHP库.zip

     ini_set('bcmath.scale', 0);  }  /**  * @covers Moontoast\Math\BigNumber::__construct  * @covers Moontoast\Math\BigNumber::getValue  * @covers Moontoast\Math\BigNumber::getScale  *...

    upscale:将图像放大到最小宽度和高度

    高档 为图像提供最小高度和宽度,并放大太小的上传... 默认情况下,这将是 500x500 像素,但可以使用过滤器cftp_upscale_minimum_width和cftp_upscale_minimum_height进行更改。 这个插件需要 Image Magick PHP 扩展

    Zend Enterprise PHP Patterns

    Understand Zend Framework and its philosophical approach to building complex yet easy-to-maintain libraries of functionality for your application that can scale with your needs. Benefit through an in-...

    usb-scale-reader:在 Linux 中从 USB 秤(来自 Stamps.com 或 DYMO)读取重量

    该库允许您使用纯 PHP 从标准 USB 秤读取重量。 可以轻松移植到其他语言,如果他们有unpack() 测试: Stamps.com 不锈钢 5 磅数字秤 DYMO M25 25 磅数字邮政秤 如果您想一目了然地了解它的工作原理,请参阅或 。...

    yii-1.0.10.r1472.zip_scaffolding_scale_yii 1.0 downlo

    Yii -- a high-performance component-based PHP framework best for developing large-scale Web applications. Yii comes with a full stack of features, including MVC, DAO/ActiveRecord, I18N/L10N, caching, ...

    php.ini-development

    [PHP] ;;;;;;;;;;;;;;;;;;; ; About php.ini ; ;;;;;;;;;;;;;;;;;;; ; PHP's initialization file, generally called php.ini, is responsible for ; configuring many of the aspects of PHP's behavior. ; PHP...

    scale3c-task:Scale3C的分配

    scale3c任务 Scale3C的分配,将HTML5模板适配到WordPress中。

    PHP Microservices

    to small, easy-to-maintain and highly available microservices and the pressing need is for PHP developers to understand the criticalities in building effective microservices that scale at large....

    Building a Web Application with PHP and MariaDB.pdf

    Building a web application that will be secure, scale well under pressure, and have an API available to different subscribers is not a simple task, but this book will make this a simple, easy-to-...

    php-image-resize:PHP库,用于调整大小,缩放和裁剪图像。 云解决方案位于:

    php-image-resize PHP库可调整大小,缩放和裁剪图像。 云解决方案 如果您不想在服务器上裁剪图像,调整图像大小并将其存储在服务器上,则是一项免费服务,可以实时处理图像并通过CDN在全球范围内提供服务。 建立 该...

    PHP 7.1.10

    Fixed bug #44995 (bcpowmod() fails if scale != 0). Fixed bug #46781 (BC math handles minus zero incorrectly). Fixed bug #54598 (bcpowmod() may return 1 if modulus is 1). Fixed bug #75178 (bcpowmod() ...

    php使用google地图应用实例

    本文实例讲述了php使用google地图应用方法。分享给大家供大家参考。具体如下: php代码如下: 复制代码 代码如下:function selected ( $param , $value ) {  ...if ( $_REQUEST [ scale ]) $scale = $_REQUEST [ scal

    Class_QRCode.php

    require_once 'Class_QRCode.php'; $NewColor = hex2rgb($Color);//转换为RGB $errorCorrectionLevel = 'L'; //容错级别 $matrixPointSize = 6; //生成图片大小 $QRUrl = $this->path . DIRECTORY_SEPARATOR . ...

    PHP精确计算功能示例

    本文实例讲述了PHP精确计算功能。分享给大家供大家参考,...function math_add($a,$b,$scale = '2') { return bcadd($a,$b,$scale); } /** * 精确减法 * @param [type] $a [description] * @param [type] $b [descr

    welcome-app:欢迎使用PHP源代码

    PHP欢迎页面 这是一个示例PHP应用程序,可用于测试OpenShift环境。 这是一个例子: user@host$ oc new-app openshift/php~https://github.com/christianh814/welcome-app ...user@host$ oc scale --replicas=3 dc/w

Global site tag (gtag.js) - Google Analytics