-
Notifications
You must be signed in to change notification settings - Fork 9
/
faq.html
executable file
·269 lines (265 loc) · 15 KB
/
faq.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
<!DOCTYPE HTML>
<html>
<head>
<!--[if lt IE 7]>
<script type="text/javascript">location.replace('/ie6/ie6.html');</script><noscript><meta http-equiv="refresh" content="0; url=/ie6/ie6.html"></noscript>
<![endif]-->
<meta charset="utf-8">
<meta name="keywords" content="phpDaemon, daemon.io, async, I/O, daemon, php, FAQ" />
<meta name="description" content="Asynchronous server-side framework for Web and network applications implemented in PHP using libevent, phpDaemon can handle thousands of simultaneous connections" />
<title>FAQ « phpDaemon</title>
<link rel="stylesheet" type="text/css" href="/css/style.css">
<link rel="stylesheet" type="text/css" href="/css/add.css">
<link rel="stylesheet" type="text/css" href="/css/shi_default.min.css">
<link rel="shortcut icon" href="/favicon.png" type="image/png" />
<link rel="icon" href="/favicon.png" type="image/png" />
<!--[if lte IE 9]>
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<link type="text/css" rel="stylesheet" href="/css/ie.css">
<![endif]-->
<!--[if lt IE 9]>
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<link type="text/css" rel="stylesheet" href="/css/ie8.css">
<![endif]-->
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-40317559-1']);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
</script>
</head>
<body>
<div id="template">
<header>
<div class="center">
<a href="/" id="logo" title="phpDaemon">phpDaemon</a>
<a href="/download.html" id="download" title="Download">DOWNLOAD</a>
<menu>
<li><span><a href="/examples.html" title="Examples">Examples</a></span></li>
<li class="active"><span><a href="/faq.html" title="FAQ">FAQ</a></span></li>
<li><span><a href="/docs/" title="Documentation">Documentation</a></span></li>
<li><span><a href="https://github.com/kakserpom/phpdaemon/issues" title="Tracker" target="_blank">Tracker</a></span></li>
<li><span><a href="/team.html" title="Team">Team</a></span></li>
<li><span><a href="/contribute.html" title="Contribute">Contribute</a></span></li>
<li><span><a href="/publications.html" title="Publications">Publications</a></span></li>
</menu>
</div>
</header>
<aside>
<div class="saw"></div>
<div class="center">
<div class="caption">
<h1 class="faq_caption">Frequently Asked Questions</h1>
<p>
Here are the most frequently asked questions about phpDaemon
</p>
</div>
</div>
</aside>
<div id="main" class="clearfix">
<div class="accordion">
<section>
<div class="section">
<div class="center">
<h2><a href="#intro">Introduction</a></h2>
<div class="accordion-content opened" style="display: block;">
<br>
<p>First of all, let me tell you what phpDaemon is. In accordance with its name, it is the network daemon built using libevent2 and eio. phpDaemon has completely asynchronous nature.
What does it mean? It means that in strong contradiction to standard Apache plus PHP, phpDaemon’s workers never block (never call <a href="http://php.net/sleep" target="_blank">sleep()</a> function). If you use PHP, in the standard way, and call any I/O function (e.g. mysql_query, fread/fwrite), these functions block the process until the operation is complete.<br>
<br>Therefore, if your script sends query to database and it takes 1 second, memory taken by PHP process is locked for 1 second. <br>Therefore, if you have 1 GB of available memory and each Apache worker takes 10 MB (it takes much more in real world), your system can handle ~100 concurrent requests at most. Response delay becomes very valuable thing. If your network or database (or any other I/O source) is lagging under the load, each request will take more time, and requests per second (RPS) goes down.<br>
In the same circumstances, phpDaemon is able to handle all of these requests using ~10 mb per CPU core, and delay of each HTTP reply does not matter at all.<br>When phpDaemon gets incoming HTTP request, it creates object of YourAppRequest class, and just destroys the object after all.</p>
</div>
</div>
</div>
</section>
<section class="odd">
<div class="section">
<div class="center">
<h2><a href="#capabilities">What types of applications can I develop using this?</a></h2>
<div class="accordion-content">
<br>
<p>Any kind of Web or network application or both in one. </p>
</div>
</div>
</div>
</section>
<section>
<div class="section">
<div class="center">
<h2><a href="#memleaks">What about memory leaks in long-running phpDaemon workers?</a></h2>
<div class="accordion-content">
<br>
<p>People often say: «you are dumb-ass if you have long-running php processes». But how bad in fact is it?
<br>
<ol>
<li>Yes, there are some internal memory leaks in PHP. But they are not significant (not more than 1-2% at worst case). You can handle a ton of requests and it will grow just a bit. You can catch it and post a bug on <a href="http://bugs.php.net/" target="_blank">bugs.php.net</a>.</li>
<li><strong>Blocking one PHP process per one running request is the biggest memory leak ever. That is what "standard" SAPIs are doing right now.</strong></li>
<li>Once phpDaemon worker goes over the memory limit (configurable thing), worker starts reloading process: it sends a signal to master process and master spawns new worker-replacer. At the same time, old worker stops accepting new connections, and waits until existing operations are being finished. That is called graceful restart.</li>
<li>Therefore little memory leaks in PHP forces us to do graceful restart of "fat" workers <b>after 50 000</b> handled requests (real number might be higher, depends on the code). But standard SAPIs are doing restarts <b>after ONE</b> request. No comments.</li>
</ol>
</p>
</div>
</div>
</div>
</section>
<section class="odd">
<div class="section">
<div class="center">
<h2><a href="#bugreporting">I have encountered a problem or bug / I have a feature request<br /> What to do?</a></h2>
<div class="accordion-content"><br>
<p><ol>
<li>If you have encountered a problem that not seems like a bug, please send your problem to Mailing list. </li>
<li>If you have encountered something looks like a bug, please <a href="https://github.com/kakserpom/phpdaemon/issues/new" target="_blank">open an issue on tracker</a>.
<li>If you have a feature request, please <a href="https://github.com/kakserpom/phpdaemon/issues/new" target="_blank">open Feature Request on tracker</a>.</li>
</ol></p>
</div>
</div>
</div>
</section>
<section>
<div class="section">
<div class="center">
<h2><a href="#port80">Why am I unable to listen on port 80 with non-root user?</a></h2>
<div class="accordion-content">
<br>
UNIX-like systems require root privilege to bind port < 1024.<br>If you put in your config something like this:<br><br>
<div class="snippet-container">
<div class="sh_default snippet-wrap">
<div class="snippet-menu sh_sourceCode">
<a class="snippet-window sh_url" href="#">pop-up</a>
<a class="snippet-text sh_url" href="#">text</a>
</div>
<pre class="shi_pre sh_css snippet-formatted sh_sourceCode"><ol class="snippet-num"><li># Not working example</li><li>user johndoe<span class="sh_symbol">;</span></li><li>group homosapiens<span class="sh_symbol">;</span></li><li>Pool<span class="sh_symbol">:</span>HTTPServer <span class="sh_cbracket">{</span></li><li> #<span class="sh_value">...</span></li><li><span class="sh_cbracket">}</span></li></ol></pre><pre class="snippet-textonly sh_sourceCode" style="display:none;" tabindex="0" contenteditable=""># Not working example
user johndoe;
group homosapiens;
Pool:HTTPServer {
#...
}</pre>
</div>
</div>
<br>
HTTPServer will be loaded after <a href="http://en.wikipedia.org/wiki/Fork_(operating_system)" target="_blank">fork</a> (in worker process) and changing user and group (<a href="http://en.wikipedia.org/wiki/Setuid" target="_blank">setuid</a>/<a href="http://en.wikipedia.org/wiki/Setgid" target="_blank">setgid</a>).<br>You shall see error message. You are not encouraged to have your workers running under <i>root</i> user.<br><br>
So if you add "privileged" statement to the config like here:<br><br>
<div class="snippet-container"><div class="sh_default snippet-wrap"><div class="snippet-menu sh_sourceCode"><a class="snippet-window sh_url" href="#">pop-up</a><a class="snippet-text sh_url" href="#">text</a></div><pre class="shi_pre sh_css snippet-formatted sh_sourceCode"><ol class="snippet-num"><li># Working example</li><li>user johndoe<span class="sh_symbol">;</span></li><li>group homosapiens<span class="sh_symbol">;</span></li><li>Pool<span class="sh_symbol">:</span>HTTPServer <span class="sh_cbracket">{</span></li><li> <span class="sh_value">privileged</span>;</li><li> #<span class="sh_value">...</span></li><li><span class="sh_cbracket">}</span></li></ol></pre><pre class="snippet-textonly sh_sourceCode" style="display:none;" tabindex="0" contenteditable=""># Working example
user johndoe;
group homosapiens;
Pool:HTTPServer {
privileged;
#...
}</pre></div></div>
<br>
and if you execute `phpd start` under <i>root</i> user then HTTPServer will be pre-loaded in master process before <a href="http://en.wikipedia.org/wiki/Fork_(operating_system)" target="_blank">fork</a>. It shall be working fine.
</div>
</div>
</div>
</section>
<section class="odd">
<div class="section">
<div class="center">
<h2><a href="#licensing">How about licensing? May LGPL cause troubles for enterprise projects?</a></h2>
<div class="accordion-content">
<br />
<p>
Not really. It does not. <a href="http://www.gnu.org/copyleft/lesser.html" target="_blank">GNU LGPL</a> (GNU Lesser General Public License) permits any usage in enterprise environment, unlike <a href="http://www.gnu.org/licenses/gpl.html" target="_blank">GNU GPL</a>. We guaratee that you will always have permission to use it in private environment.<br /><br />
The only thing which LGPL requires is that you should open your modifications applied to code of phpDaemon. Any linked code might be private.
</p>
</div>
</div>
</div>
</section>
<section>
<div class="section">
<div class="center">
<h2><a href="#drivers">I want to use SuperduperfancyDB in my application, but unable to find driver for it. What to do?</a></h2>
<div class="accordion-content">
<br>
<p>
<ol>
<li>If you are a proficient programmer you can build a client by analogy with others. This is not difficult. Consider <a href="/contribute.html">sharing</a> it.</li>
<li>If you are not enough skilled or just do not want to develop it yourself, you should <a href="https://github.com/kakserpom/phpdaemon/issues/new" target="_blank">open a Feature Request</a> on <a href="https://github.com/kakserpom/phpdaemon/issues" target="_blank">Tracker</a>, and perhaps it will appear <strong>in a day or two</strong>. Do not sit and wait, just <a href="https://github.com/kakserpom/phpdaemon/issues/new" target="_blank">open an FR</a>.
</li>
</ol>
</p>
</div>
</div>
</div>
</section>
<section class="odd">
<div class="section">
<div class="center">
<h2><a href="#logs">I just installed it, ran `phpd start` and nothing seems to happen. Why?</a></h2>
<div class="accordion-content">
<br>
<p>Logging to TTY is disabled by default. By default, log messages are going only to file.</p>
<ol>
<li>You can use `phpd log` to interactively watch the log (tail -f).</li>
<li>You can run `phpd start --verbose-tty=1` to watch it your terminal. Useful in development environment, not in production.</li>
</ol>
</div>
</div>
</div>
</section>
<section>
<div class="section">
<div class="center">
<h2><a href="#configuration">How to find and edit configuration?</a></h2>
<div class="accordion-content">
<br>
<ol><li>Default config-path: <i>/etc/phpdaemon/phpd.conf;/etc/phpd/phpd.conf;./conf/phpd.conf</i></li>
<li>If you want to output your current configuration, use the following command: <i>phpd configtest</i></li>
<li>You should add necessary sections to your config file, like Pool:FastCGI, MyOwnApp and other.</li>
</ol>
</div>
</div>
</div>
</section>
<section class="odd">
<div class="section">
<div class="center">
<h2><a href="#contribute">How can I help?</a></h2>
<div class="accordion-content"><br >
<p>
Please check this section out: <a href="/contribute.html">Contribute</a>
</p>
</div>
</div>
</div>
</section>
</div>
<section>
<div class="section">
<div class="center">
<center><h2>To be continued.....</h2></center>
</div>
</div>
</section>
</div>
</div>
<footer>
<div class="center">
<a href="http://validator.w3.org/check?uri=http%3A%2F%2Fdaemon.io%2F" title="W3C HTML 5" target="_blank" class="w3chtml5"><img src="/img/w3chtml5.png" alt="W3C HTML 5" width="88" height="31"></a>
Send us your questions and they have a chance to be here
</div>
</footer>
<div class="scrollup"></div><div class="scrolldown"></div>
<script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jqueryui/1.10.2/jquery-ui.min.js"></script>
<script type="text/javascript" src="/js/common.js"></script>
<!-- AddThis Button BEGIN -->
<div class="addthis_toolbox addthis_floating_style addthis_16x16_style" style="top:50px;background:none;opacity:0.70">
<a class="addthis_button_twitter" addthis:title="#Asynchronous server-side framework for Web and network applications implemented in #PHP using libevent, check out" addthis:url="http://daemon.io/"></a>
<a class="addthis_button_reddit"></a>
<a class="addthis_button_facebook"></a>
<a class="addthis_button_google_plusone_share"></a>
<a class="addthis_button_digg"></a>
<a class="addthis_button_compact"></a>
</div>
<script type="text/javascript" src="//s7.addthis.com/js/300/addthis_widget.js#domready=1"></script>
<!-- AddThis Button END -->
<a href="https://github.com/kakserpom/phpdaemon" class="forkButton" target="_blank"><img src="/img/forkme.png" height="149" width="149" alt="Fork me on GitHub"></a>
</body>
</html>