# Performance and FastCGI - Very Good Results

**URL:** https://discussions.eramba.org/t/performance-and-fastcgi-very-good-results/979
**Category:** Forum - Software
**Created:** [March 13, 2019, 4:25pm UTC](https://discussions.eramba.org/t/performance-and-fastcgi-very-good-results/979 "2019-03-13T16:25:32Z")
**Posts on this page:** 12
**Page:** 1

<div class="post-metadata">

### Author: ![jsalehy](https://discussions.eramba.org/letter_avatar_proxy/v4/letter/j/ecc23a/32.png) [@jsalehy](https://discussions.eramba.org/u/jsalehy)
#### Post date: [March 13, 2019, 4:25pm UTC](https://discussions.eramba.org/t/performance-and-fastcgi-very-good-results/979/1 "2019-03-13T16:25:32Z")

</div>

Just wanted to share my experience trying to speed up the system by switching to using the fastCGI process manager on Apache 2.4 - specifically using mod\_proxy\_fcgi.

It wasn’t too difficult to get everything working. The main thing was to make sure the required php settings ended up in the right config file.

The speed increase was quite significant, however I’m still trying to get daily crons to run correctly. I think there’s a timeout somewhere that I must be missing - most likely proxy related. Once I figure out what’s going on, it shouldn’t be too hard to resolve.

In any case, if anyone is planning on going down this road, I think it can be worthwhile. In my (un-scientific) testing, I’m seeing about a 50% speed increase in page loads.

---

<div class="post-metadata">

### Author: ![eramba](https://discussions.eramba.org/letter_avatar_proxy/v4/letter/e/c6cbf5/32.png) [@eramba](https://discussions.eramba.org/u/eramba)
#### Post date: [March 13, 2019, 4:45pm UTC](https://discussions.eramba.org/t/performance-and-fastcgi-very-good-results/979/2 "2019-03-13T16:45:13Z")

</div>

possibly very very juicy 🙂

what ProxyPassMatch you have on your virtual host? im stuck there

---

<div class="post-metadata">

### Author: ![eramba](https://discussions.eramba.org/letter_avatar_proxy/v4/letter/e/c6cbf5/32.png) [@eramba](https://discussions.eramba.org/u/eramba)
#### Post date: [March 13, 2019, 4:49pm UTC](https://discussions.eramba.org/t/performance-and-fastcgi-very-good-results/979/3 "2019-03-13T16:49:31Z")

</div>

Without FPM:

 ![image](https://discussions.eramba.org/uploads/default/original/1X/616f7da605f387e17d915fdadb6bf581cf5044b2.png)

With FPM:

 ![image](https://discussions.eramba.org/uploads/default/original/1X/e5e4a36b272cc0c63dac78648481a13e0df3fa8b.png)

Do you get similar readings?

---

<div class="post-metadata">

### Author: ![eramba](https://discussions.eramba.org/letter_avatar_proxy/v4/letter/e/c6cbf5/32.png) [@eramba](https://discussions.eramba.org/u/eramba)
#### Post date: [March 13, 2019, 4:59pm UTC](https://discussions.eramba.org/t/performance-and-fastcgi-very-good-results/979/4 "2019-03-13T16:59:26Z")

</div>

Steps on ubuntu:

1/ installed fpm module with apt (php7.0-fpm)  
2/ configured this /etc/php/7.0/fpm/pool.d/www.conf , by adding “listen = 127.0.0.1:9000” (before was a socket)  
3/ included this on the virtual host: ProxyPassMatch ^/(._.php(/._)?)$ fcgi://127.0.0.1:9000/var/www/acunetix.eramba.org/eramba\_v2/$1  
4/ loaded the following php modules: proxy\_fcgi  
5/ restarted apache and voila

---

<div class="post-metadata">

### Author: ![jsalehy](https://discussions.eramba.org/letter_avatar_proxy/v4/letter/j/ecc23a/32.png) [@jsalehy](https://discussions.eramba.org/u/jsalehy)
#### Post date: [March 13, 2019, 7:07pm UTC](https://discussions.eramba.org/t/performance-and-fastcgi-very-good-results/979/5 "2019-03-13T19:07:33Z")

</div>

With fastCGI mpm\_prefork isn’t ideal. You really want to use mpm\_event or mpm\_worker, but it’s a little tricker to set up. Also, depending on your server memory, there’s a lot of tuning you can do for php-fpm (www.conf) and apache (mpm\_event.conf or mpm\_worker.conf)

Here were my steps…

Disabled mpm\_prefork, mod\_php7.0  
Enabled mpm\_event, proxy\_fcgi  
I didn’t use ProxyPassMatch - it causes some issues with .htaccess. I did this instead…

ProxyTimeout 600  
\<FilesMatch .php$\>  
SetHandler “proxy:unix:/var/run/php/php7.0-fpm.sock|fcgi://localhost/”

Added all the Eramba required php settings to /etc/php/7.0/fpm/php.ini

---

<div class="post-metadata">

### Author: ![jsalehy](https://discussions.eramba.org/letter_avatar_proxy/v4/letter/j/ecc23a/32.png) [@jsalehy](https://discussions.eramba.org/u/jsalehy)
#### Post date: [March 14, 2019, 2:42pm UTC](https://discussions.eramba.org/t/performance-and-fastcgi-very-good-results/979/6 "2019-03-14T14:42:52Z")

</div>

Just FYI, I’m still having an issue with the daily cron. I really hope I can solve it because fpm makes things so much more responsive.

---

<div class="post-metadata">

### Author: ![eramba](https://discussions.eramba.org/letter_avatar_proxy/v4/letter/e/c6cbf5/32.png) [@eramba](https://discussions.eramba.org/u/eramba)
#### Post date: [March 15, 2019, 8:12am UTC](https://discussions.eramba.org/t/performance-and-fastcgi-very-good-results/979/7 "2019-03-15T08:12:21Z")

</div>

I had no issues running crons so my guess is something on your end - firewalls most likely if you have timeouts , please schedule a call with [support@eramba.org](mailto:support@eramba.org) !

---

<div class="post-metadata">

### Author: ![eramba](https://discussions.eramba.org/letter_avatar_proxy/v4/letter/e/c6cbf5/32.png) [@eramba](https://discussions.eramba.org/u/eramba)
#### Post date: [March 15, 2019, 2:49pm UTC](https://discussions.eramba.org/t/performance-and-fastcgi-very-good-results/979/8 "2019-03-15T14:49:53Z")

</div>

another update here - it seems that api’s basic auth is not working with fastcgi unless we change a fwe things, we’ll put the fix to give this another shot.

int ref: [https://github.com/eramba/eramba\_v2/issues/2060](https://github.com/eramba/eramba_v2/issues/2060)

---

<div class="post-metadata">

### Author: ![eramba](https://discussions.eramba.org/letter_avatar_proxy/v4/letter/e/c6cbf5/32.png) [@eramba](https://discussions.eramba.org/u/eramba)
#### Post date: [November 8, 2019, 1:59pm UTC](https://discussions.eramba.org/t/performance-and-fastcgi-very-good-results/979/9 "2019-11-08T13:59:59Z")

</div>

@jsalehy i was looking today at fpm server to offload some specific URIs to an alternative server other than the main server. the idea is the browser hits a normal apache+fpm+mysql server but apache has an additional proxy setting that forwards /securityServices URI to another server running fpm

 ![image](https://discussions.eramba.org/uploads/default/original/2X/f/f42ab8a1f8bbc887f048b128f0351e20983dc6f3.png)

For some reason some things are not as i expect..

On the main server i thought FPM was working (i saw packets on port 9001) but when i looked at the fpm server access logs no matter what section of eramba i use i see only this logs only:

```
root@dev:/etc/php/7.2/fpm/pool.d# tail -f /var/log/apache2/www.access.fpm.log 
127.0.0.1 - 08/Nov/2019:13:45:11 +0000 "GET /app/webroot/index.php" 200
127.0.0.1 - 08/Nov/2019:13:45:14 +0000 "GET /app/webroot/index.php" 200
127.0.0.1 - 08/Nov/2019:13:45:13 +0000 "GET /app/webroot/index.php" 200
127.0.0.1 - 08/Nov/2019:13:45:24 +0000 "GET /app/webroot/index.php" 200
127.0.0.1 - 08/Nov/2019:13:45:26 +0000 "GET /app/webroot/index.php" 200

```

My virtual host on apache has only one line (the one above is for the redirection for a specific uri)

 ![image](https://discussions.eramba.org/uploads/default/original/2X/4/4c10f4c14440e187f47fb4375acc78e84043a3f6.png)

I’m not entirely sure what im doing wrong .. seems like fpm does not understand the .htaccess on eramba (rewrites, etc) ? .. the weird thing is i dont get an error on the browser, i get eramba served by the apache built in php module.

 ![image](https://discussions.eramba.org/uploads/default/original/2X/5/5ed0b131f8e6bd3a0990781d07d9e5141c6ac524.png)

So i thought FPM was working but from the debug above you can see standard php is serving content…i think you mention on your post something about this but i’m not sure what the solution is. maybe you can enlighten?

In regards to the other attempt (redirect a single uri) i get a “File not found” error on the browser, the fpm logs on that server shows:

```
root@tmpdev:/etc/php/7.2/fpm/pool.d# cat /var/log/apache2/www.access.log 
172.21.2.186 - 08/Nov/2019:13:36:09 +0000 "GET /securityServices" 404
172.21.2.186 - 08/Nov/2019:13:36:34 +0000 "GET /securityServices" 404

```

…

---

<div class="post-metadata">

### Author: ![eramba](https://discussions.eramba.org/letter_avatar_proxy/v4/letter/e/c6cbf5/32.png) [@eramba](https://discussions.eramba.org/u/eramba)
#### Post date: [November 8, 2019, 2:30pm UTC](https://discussions.eramba.org/t/performance-and-fastcgi-very-good-results/979/10 "2019-11-08T14:30:02Z")

</div>

Ok - i had an issue on my regex matching php files so now it works , just in case i disabled mod\_php on apache and pages load. i still find it weird that the fpm access log shows only index.php no matter what i throw at eramba…no idea why really.

I’ll now keep working on the URI redirect , we want to off load crons to an alternative server. let us know if you tried something like that with success!

---

<div class="post-metadata">

### Author: ![jsalehy](https://discussions.eramba.org/letter_avatar_proxy/v4/letter/j/ecc23a/32.png) [@jsalehy](https://discussions.eramba.org/u/jsalehy)
#### Post date: [November 8, 2019, 3:44pm UTC](https://discussions.eramba.org/t/performance-and-fastcgi-very-good-results/979/11 "2019-11-08T15:44:26Z")

</div>

Just FYI, I had to add this to my virtual host as well…

SetEnvIf Authorization “(.\*)” HTTP\_AUTHORIZATION=$1

---

<div class="post-metadata">

### Author: ![eramba](https://discussions.eramba.org/letter_avatar_proxy/v4/letter/e/c6cbf5/32.png) [@eramba](https://discussions.eramba.org/u/eramba)
#### Post date: [November 8, 2019, 4:39pm UTC](https://discussions.eramba.org/t/performance-and-fastcgi-very-good-results/979/12 "2019-11-08T16:39:15Z")

</div>

On the fpm logs, you also get only that index.php entry?  
i mean mine has to be working, php mod is disabled from apache all-together so there is no other way this would be working …
