I have large photo file and would like to use gwan as it fast. Is there any performance benefits in comparison to nginx fast-cgi. Does gwan fast at timd to first byte? Is it faster at connecting time? Is commputing time faster? Is throughput faster?Furthermore can you install hhvm on gwan. If you can, how would you install hhvm?would it give a performance benefit to php(how much)?
-
HHVM and speed? You mean speed in failing to run or? Don't waste your time with that crap, if you're hunting performance without resorting to languages like C, use beta of php 7. It might not be finished yet fully, but it's as fast as HHVM and most importantly - it works, and when it fails - it tells you why. HHVM doesn't. – N.B. Jun 09 '15 at 09:25
-
Thanks for the clarification. We got good reports from G-WAN + PH7 users. – Gil Jun 10 '15 at 12:41
2 Answers
The only way you are going to know if nginx or G-WAN are better for your use case is to actually use them for your site and benchmark it. The speed of software like this depend very much on your configuration, usage patterns, site structure, etc etc, and is not something where a single blanket answer is appropriate or useful.
HHVM can be used behind any webserver which can serve FastCGI requests. A quick google search indicates that G-WAN may not support FastCGI, but rather has its own custom scripting interface? If so, it may still be possible to use that interface to integrate HHVM, though it is likely to require some work and not be officially supported.

- 7,060
- 1
- 18
- 26
The downside of FasCGI
is that it's itself a backend server: instead of having only G-WAN as a server, you are limited by the speed of the backend server when G-WAN sends it requests and waits its replies:
Internet LAN
[clients] ============ [G-WAN] ----------------- [FastCGI + PHP]
latency1 latency2 latency3 latency4 latency5
In this case, the latency of a FastCGI
server and the extra LAN latency are slowing-down G-WAN.
A more efficient way is to have G-WAN load and run the HHVM
itself, which has been done with PH7
, another thread-safe PHP runtime provided with G-WAN v4+:
Internet
[clients] ============ [G-WAN + PHP]
latency1 latency2 latency3
It is technically possible to implement *.hhvm
G-WAN scripts like it has been done for G-WAN *.ph7
, *.java
, *.scala
and *.cs
(C#) scripts. This requires writting a G-WAN C module to load the HHVM
in the G-WAN memory-sapce (something that may take time depending on the level of support provided by the Facebook HHVM team).
One could also use the G-WAN CGI interface to invoke HHVM
as a local process (like G-WAN was forced to do for the thread-unsafe Zend PHP). But the results in terms of performance greatly depend on the initialization and processing times of the HHVM
executable (not to mention the extra per-request overhead). This third way is simpler to implement but necessarily slower than a native HHVM
G-WAN module.

- 3,279
- 1
- 15
- 25
-
Oh, here we go again - [PHP is thread safe](http://php.net/manual/en/faq.obtaining.php#faq.obtaining.threadsafety). One just has to ensure stuff exists :) – N.B. Jun 09 '15 at 09:23
-
Yet, once you embedd the Zend PHP engine in a multithreaded C program then it crashes as soon as you have 2 threads (even with a simple hello world). We have requested assistance from Zend for years - providing them with our embedded C source code and they never told us they managed to make it work. We would be DELIGHTED to have a working version. – Gil Jun 10 '15 at 12:39
-
Alright, from what I read about your server, it looks great. I'd love to be able to use PHP with it, even if just for fun. I'd also like to help, and I also know that Zend isn't that responsive when in need for help - which is why it's always better to turn to people who maintain PHP and aren't part of Zend. Is there any chance you can provide any kind of code so the rest of us can have a stab at it? Even the hello world would suffice. I'm interested to see how the thread safe php fails with your server, it might be a huge mistake at PHP's end. – N.B. Jun 10 '15 at 12:45
-
@N.B. Gil posted the code [here](http://stackoverflow.com/questions/27353520/how-to-use-gwan-with-wordpress-installation-through-php-fpm) and it seems you also participated in the discussion. – Nagi Jun 11 '15 at 09:17
-
@Nagi - thanks, I didn't see that code since it was edited a few months after my comments. Going to take a look at it. – N.B. Jun 11 '15 at 12:42
-
So, from taking a look at various extensions and one specific macro - `TSRMLS_FETCH();` - I can't see it in the mentioned C code. That code also complains about `tsrm_ls` not being defined. Googling a bit suggests one must do `TSRMLS_FETCH();` or the macros won't work. Any comments? – N.B. Jun 11 '15 at 13:09
-
If you or anyone else manages to make this code work then we will gladly integrate it to G-WAN. We can't comment things that are left undocumented by PHP, like the portions of code which remain undefined and not available online at least at the time of our research. We also have contacted a few 'external' PHP maintainers without success. – Gil Jun 12 '15 at 06:50
-
Additional useful resources that I dug up, along with some nice comments: [here](https://github.com/basvanbeek/embed2-sapi). I'll play with the code once I manage to free up my schedule, I believe that the issue lies in not calling the macro which enables the rest of the TSRM_* family. – N.B. Jun 12 '15 at 11:00
-
Compiling PHP is another challenge when facing unresolved symbols that are... not defined in the distribution archive. – Gil Jun 13 '15 at 14:59