Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:74839 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 69371 invoked from network); 11 Jun 2014 06:16:53 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 11 Jun 2014 06:16:53 -0000 Authentication-Results: pb1.pair.com smtp.mail=swhitemanlistens-software@cypressintegrated.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=swhitemanlistens-software@cypressintegrated.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain cypressintegrated.com designates 173.1.104.101 as permitted sender) X-PHP-List-Original-Sender: swhitemanlistens-software@cypressintegrated.com X-Host-Fingerprint: 173.1.104.101 rproxy2-b-iv.figureone.com Received: from [173.1.104.101] ([173.1.104.101:62083] helo=rproxy2-b-iv.figureone.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 26/B0-62015-354F7935 for ; Wed, 11 Jun 2014 02:16:52 -0400 Received: from 124.1.168.192.in-addr.arpa ([108.12.130.219]) by rproxy2-b-iv.figureone.com (Brand New Heavy v1.0) with ASMTP id XMB99247 for ; Tue, 10 Jun 2014 23:16:47 -0700 Date: Wed, 11 Jun 2014 02:16:41 -0400 Reply-To: Sanford Whiteman X-Priority: 3 (Normal) Message-ID: <557316051.20140611021641@cypressintegrated.com> To: Kevin Ingwersen In-Reply-To: References: <2C3AA922-B514-45C0-940E-EBF6F931BCE1@googlemail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: quoted-printable Subject: Re: [PHP-DEV] Own webserver, with PHP plus opcache/similar? From: swhitemanlistens-software@cypressintegrated.com (Sanford Whiteman) > I run them once, and part of it, like classes and such, stay in > memory, instead of having to =84recompile=93 the script. I thought this > is doen using OPcache=85 OPcache and other bytecode caches accelerate PHP in two ways that meet your needs as described: [1] They enable PHP to run compiled bytecode, if available, instead of your raw(er) script code, improving response time and reducing CPU demand. [2] They retain that bytecode in memory, reducing disk I/O demand (after initial load and compile) to only fast freshness checks. Some caches allow disabling such checks completely or running them only periodically. (Those setups require a process restart, manual flush, or a time delay in order to pick up file changes.) So far, so good. But be wary of expecting full-time magic from opcode caches. For one thing, they must be rebuilt across server restarts (being memory-based and all*). They'll also be destroyed -- necessitating a reload of all pages -- in other situations, depending on your web server + SAPI. If no PHP processes are running, there's nothing to hold onto shared memory: imagine if all FastCGI workers exit due to idle timeout, or if your webserver launches worker threads and you restart it. And I know of one cache that is otherwise stable and fast, but forcibly empties itself every 15m (or maybe it's 30m?). All these are recipes for periodic resource spikes after long periods of calm, but that's something you live with. Caches also have a policy of automatic eviction of individual records, after a period of disuse and/or when there is known memory pressure, i.e. the memory allocated for the cache is running low. Thus a given page can't be *guaranteed* to be cached at any point in time. Frequently used pages are *almost* guaranteed to be cached and *on average* any other pages that see traffic will run from cache. Just not Every. Single. Time. Caching does not obviate the need to write tight code and have a worthy disk subsystem and CPU. It just means well-written code will run even lighter and faster. tl;dr: if you use any SAPI that stays running after a request (i.e. anything other than old CGI) an opcode cache not only meets your reqs but is, frankly, mandatory (that's why OPcache was added to 5.5). -- Sandy * You can also look into caches that use a disk layer to add persistence. Terry Ellison had worked on a fork of OPcache. Once you expand into disk caching it is also worthwhile to think about *output* caching (response fragments, et al.) not just bytecode caching.