MVC4 / Mono 3.2.1 application is running in Debian with Nginx and mono-fastcgi-4 server. It is started as
MONOSERVER=$(which fastcgi-mono-server45)
WEBAPPS="/:/var/www/html/test/"
${MONOSERVER} /applications=${WEBAPPS} /socket=tcp:127.0.0.1:9000 &
For testing, browser F5 key is hold down for 30 seconds. After that there is long delay, browser shows page load icon. After delay message
504 Gateway Time-out
nginx/0.7.67
appears
and top command (output below) shows that mono fastcgi server takes 200% cpu forever or for a long time (2 cores). Only way to stop this is to kill mono fastcgi server manually and manually to restart it
How to make mono fastcgi to return pages immediately and not use so much cpu ?
If same application is hosted with Apache and mod_mono , holding and releasing F5 key in browser returns page immediately and cpu usage goes to 0 immediately after F5 is released in browser.
top - 00:40:38 up 1:43, 3 users, load average: 16.49, 15.92, 15.35
Tasks: 59 total, 1 running, 58 sleeping, 0 stopped, 0 zombie
Cpu(s): 34.5%us, 65.5%sy, 0.0%ni, 0.0%id, 0.0%wa, 0.0%hi, 0.0%si,
0.0%st
Mem: 2097152k total, 744828k used, 1352324k free, 0k buffers
Swap: 0k total, 0k used, 0k free, 120120k cached
PID VIRT RES SHR %CPU %MEM TIME+ COMMAND
4366 500m 121m 21m 198 5.9 6:24.45 /opt/mono-3.2/bin/mono
/opt/mono-3.2/lib/mono/4.5/fastcgi- ....
Update
Answer in Bad gateway 502 after small load test on fastcgi-mono-server through nginx and ServiceStack
recommends to use same number of threads in nginx and in fastcgi server.
I'm using default nginx and mono fastcgi server configuraton where both probably allow 1024 threads.
- Will mono allow actually less threads. Maybe this causes the issue, fastcgi mono server is very old?
- Can adding /multiplex to fastcgi mono server fix this?
- Is it resonable to decrease number of threads for this not very powerful VPS server above ?
- Are there some mono settings which cause the failure ?
- Nothing is written to fastcgi log file, how to diagnose this ?
Additional information about this is posted in https://stackoverflow.com/questions/20512978/how-to-limit-mono-197-cpu-usage-in-mono-fastcgi-server