A month back, we have faced an issue of memory out of space which leads the server crash. We have solved this issue with help of following script. This script is sending an kill signal rails instance which is taking a more memory. Due to this crash will be get notified at client side.
This script is use full for monitoring rails instance of passenger. As other available tools are not able to monitor rails instance which is maintained by passenger.
It will monitor rails instance such that, it will kill rails instance which is taking more than 500MB and if rails instance has processed 200 requests.
After killing rails instance, passenger will automatically fork another rails instance if required.
The reason of restarting instance after certain requests, to keep memory available for other rails instances. Since I have found an articles which are saying "Rails expands the Ruby process so much that additional memory allocation grows much larger than we actually need, due to the exponential growth factor. And since MRI never gives back unused memory"
I have saw passenger has PassengerMaxRequests and PassengerMaxMemory (Not sure) for Apache server but not available for nginx.
My script will do the same thing for nginx :).
Open any file,
e.g
e.g
and paste following code in it.
Then give execute permission to the file
And then run this script as super user
Note:
If you want to run this script as background process on server
No comments:
Post a Comment