Photon

Photon Git Source Tree

Root/doc/principles.mdtext

1# Photon Principles
2
3The core priorities of the Photon project are:
4
5- Speed.
6- Ease of development.
7
8Starting version 1.0 speed regressions will not be allowed. That is,
9each new version of Photon will have to be at least as fast as the
10previous if not better for a set of standardized tests.
11
12# Technology
13
14Daemon. Yes, a daemon in PHP. This works perfectly well as it is used
15in combination with Mongrel2. Mongrel2 allows us to start/stop daemons
16in PHP extremely easily without disruption of the requests. For
17example, you can set your daemon to shut itself down after 500
18requests or after reaching a certain level of memory consumption. You
19let the mongrel2 process supervisor restart the process (it is PHP so
20it is extremely fast) and you just enjoy automatic cleaning of the
21memory leaks while getting an extremely robust system.
22
23Depending on your system (that is, if you have many cores) you can run
24many backend PHP processes to fully use your cores and get the maximum
25out of your system. You can also have a smart way to start/stop PHP
26backend processes depending on the load (you can even start them on
27other systems).
28
29# Methodology
30
31In memory. The goal is to hit the disk only when really needed. So all
32the tradeoffs are towards putting more in memory and have less disks
33access and system calls.
34
35Cryptography to allow stateless communication (signed cookies) and
36permit authentication without the need to hit the database or even
37open a connection to the database.
38
39Smart "core" objects which are database independent even so most of
40the code is structured to take benefit of MongoDB.
41
42MongoDB, because it is fast and nicely answers our needs:
43
44- Fast development of new models.
45- No real needs of migrations, they can be handled at the code level on a running system.
46- Memory mapped, that is, no disk access when the dataset is small.
47
48Use PHP. This may be a surprising remark, but most of the frameworks
49tend to reinvent the PHP builtin functions and classes, just don't do
50it. Use PHP as much as possible, this is faster and safer on the long
51run.
52
53# Critics
54
55It Sucks, I Cannot Use It On Shared Hosting. Yes, but the goal here is
56to provide a high performance PHP framework for websites with
57performance constraints. If you are on a shared hosting, you would be
58better served with a already very fast framework like Pluf.
59
60A daemon in PHP, PHP is a memory sieve, so we can forget about
61it. Already the fast-cgi approach has a per children request limit
62(500 by default) to kill and restart a children after a while to plug
63the memory leaks. So, this is the same approach.
64
65ømq is another piece of infrastructure we do not need. Yes and no, the
66wonder of ømq is that we can even use it to dispatch the requests to
67other processes (Python, Ruby, Java) to offload some of the work to
68specialized systems.
69

Archive Download this file

Branches

Tags