Re: Persistent PHP web application?
| From: | Matthew Weier O'Phinney | Date: | Mon, 03 Jan 2005 17:07:45 +0000 |
| Subject: | Re: Persistent PHP web application? | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-205537@lists.php.net to get a copy of this message | ||
* Josh Whiting <jw-php@valleyfree.com>:
> My web application (an online classifieds server) requires a set of
> fairly large global arrays which contain vital information that most all
> the page scripts rely upon for information such as the category list,
> which fields belong to each category, and so on. Additionally, there are
> a large number of function definitions (more than 13,000 lines of code
> in all just for these global definitions).
>
> These global arrays and functions never change between requests.
> However, the PHP engine destroys and recreates them every time. After
> having spent some serious time doing benchmarking (using Apache Bench),
> I have found that this code takes at least 7ms to parse per request on
> my dual Xeon 2.4ghz server (Zend Accelerator in use*). This seriously
> cuts into my server's peak capacity, reducing it by more than half.
>
> My question is: is there a way to define a global set of variables and
> functions ONCE per Apache process, allowing each incoming hit to run a
> handler function that runs within a persistent namespace? OR, is it
> possible to create some form of shared variable and function namespace
> that each script can tap?
Run it as a SOAP server, and have the web requests communicate with the
SOAP server. That way you can keep the heavy-hitting stuff in memory,
but still maintain the flexibility of a traditional PHP web app.
PHP5 has native soap functions (http://php.net/soap), but you could also
use the PEAR SOAP libraries (http://pear.php.net/packages/soap).
--
Matthew Weier O'Phinney | mailto:matthew@garden.org
Webmaster and IT Specialist | http://www.garden.org
National Gardening Association | http://www.kidsgardening.com
802-863-5251 x156 | http://nationalgardenmonth.org