MONO 4.6.2 High CPU Usage on Server

2019-02-18 03:01发布

I have updated my:

  • Ubuntu server to 16.04.1 LTS and
  • MONO to v4.6.2

...from official repository.

Since the update, the websites are still running fine, but after about a day or two, some of the MONO processes go crazy and take 100% of the CPU. I have different websites; mostly plain HTML with just a little bit of code. It happens randomly, and on different websites each time. It's totally random.

I then receive an email alert of high CPU usage, connect via SSH, type "htop", and kill the process and it's back to normal ... for a day or two.

This definitely looks like a bug in this version of MONO. Any way to fix it? Anyone else had this problem? Or perhaps I should switch to a different version that doesn't have this corruption?

Thanks

Edit: After 2 days, EVERY MONO process is taking up the full CPU.

Looking into the Apache2 log file, I could find this related to MONO

WARNING: WebConfigurationManager's LRUcache evictions count reached its max size
Cache Size: 100 (overridable via MONO_ASPNET_WEBCONFIG_CACHESIZE)

Also, "service apache2 restart" does not solve the problem. I must manually kill the processes, or reboot.

2条回答
Viruses.
2楼-- · 2019-02-18 03:27

After trying all options, it seems MONO just doesn't work well with Apache2 with mod_mono. The only solution I found is to switch Apache2 from prefork to worker mode, where the MONO server needs to be started manually and Apache2 simply forwards the requests to it -- and thus Apache2 doesn't directly touch MONO at all. There is very little documentation on how to do this, but since NGINX works in that mode, you can find instructions on how to set it up for NGINX and translate the app config file for Apache2.

These are good places to start

http://www.mono-project.com/docs/web/fastcgi/nginx/

http://epmjunkie.com/mono-fastcgi-startup-script/

查看更多
相关推荐>>
3楼-- · 2019-02-18 03:38

I have played around with various MONO versions, and typing "service apache2 reload" to reproduce the high CPU usage problem.

In MONO 4.8, it seems to happen to happen a bit less often but the problem is still there.

In MONO 4.2.3.4, the problem is also there.

In MONO 4.2.1 that comes by default on Ubuntu, this problem doesn't happen.

As for .NET Core, some have tried it and highly recommended me to avoid it until it becomes more stable.

So for now, the only solution is to stick to MONO 4.2.1

This also confirms that this is related to MONO and not to my code or the server configuration.

查看更多
登录 后发表回答