[Urgent] Need script performance optimization..

ollie

Member
YetiShare User
Apr 25, 2013
75
5
8
United Kingdom
Hi, i am in need of performance optimizations, my site has gotten pretty big over the past year and the script is started to hold me back from expanding.

First of all here is my file server specs.

--HW--
Intel E3 1270v3
32GB RAM
120GB SSD
4x4TB HDDs
10Gbps Unmetered

--SW--
Nginx
php-fpm

The problem i have is at peak times when there can be around 1000 people all downloading at once. This means that there must be 1000 php-fpm processes or else the server will grind to a halt. On top of that the max execution time must be set to a high number (I have mine at 4 hours) otherwise the downloads will just cut off when the time is up.

I wan't to know is it possible to cut the file download script off as soon as the download is started so its just pulling from nginx only? If not how does other big file sharing sites do it? This is the problem i have at the moment. http://puu.sh/aIwK0/bc490b0509.png

Thanks
 

ollie

Member
YetiShare User
Apr 25, 2013
75
5
8
United Kingdom
http://puu.sh/aIBPu/823f172722.png

People are saying uploading is incredibly slow and uploads are stalling, need this fixed asap :(
 

coffee

New Member
Jul 23, 2014
83
0
0
This could even be a very helpful thread all around if people threw out tips. Maybe some of them could even help you or give you an idea.

What about putting your database on another server?

Or maybe getting a custom mod made for the player that stops downloading after 30 seconds or so if a user clicks pause (and resumes upon clicking play again)? I can't imagine all the wasted bandwidth due to a user clicking play, pausing, letting it load only to just close the window or watch 20 seconds and stop.

I'm going to assume you're already using a cdn service, but for those that are not:
https://www.cloudflare.com - free plan
http://swarmify.com/plans/ - supposed to help video hosting. Beta small free plan
http://www.incapsula.com/ - free plan
https://cdnify.com/pricing - no free plan
http://www.cdn77.com/video-cdn - streaming. free trial. They do normal cdn too
 

ollie

Member
YetiShare User
Apr 25, 2013
75
5
8
United Kingdom
You guys are not understanding, its the file servers, it cannot take more than 1000 active connections before the CPU maxes out, this is because a php-fpm process needs to stay running for the download. I have been forced to move now anyway since support has not replied to any of my emails in a month now.
 

ollie

Member
YetiShare User
Apr 25, 2013
75
5
8
United Kingdom
his could even be a very helpful thread all around if people threw out tips. Maybe some of them could even help you or give you an idea.

What about putting your database on another server?

Or maybe getting a custom mod made for the player that stops downloading after 30 seconds or so if a user clicks pause (and resumes upon clicking play again)? I can't imagine all the wasted bandwidth due to a user clicking play, pausing, letting it load only to just close the window or watch 20 seconds and stop.

I'm going to assume you're already using a cdn service, but for those that are not:
https://www.cloudflare.com - free plan
http://swarmify.com/plans/ - supposed to help video hosting. Beta small free plan
http://www.incapsula.com/ - free plan
https://cdnify.com/pricing - no free plan
http://www.cdn77.com/video-cdn - streaming. free trial. They do normal cdn too

I am already using incapsula paid and MaxCDN, that is not the problem, the script is the problem.
 

adam

Administrator
Staff member
Dec 5, 2009
2,046
108
63
I spent some time yesterday working over this to get these performance issues resolved. The main problem was php-fpm processes being maxed out because of the current downloads. These were all being handled via PHP, so if a download took 6 hours, that would tie up a single PHP process for this period. This is fine on smaller sites but clearly it doesn't scale too well as the site grows.

I set it to use X-Accel-Redirect in NGINX instead which basically enables the download process to be off-loaded from PHP onto NGINX straight after the request. As NGINX is designed to handle files there's been a dramatic improvement in CPU usage and amount of php-fpm processes running.

These changes are already scheduled for the next code release aswell as the Apache version (X-Sendfile). Although I'd recommend using Nginx.
 

zigma4000

Member
YetiShare User
Wurlie User
Jun 9, 2013
39
0
6
UAE
www.uploadman.com
well I have same issue and php-fpm takes alot of memory for each download.

for example a downloader with 8 concurrent connections takes about 500MB of RAM.

my server has 16GB ram , which means only 32 people can download with 8 concurrent connections then server is fully loaded !

I thought something was wrong with my PHP-fpm and Nginx configurations till I saw this topic.
 

adam

Administrator
Staff member
Dec 5, 2009
2,046
108
63
zigma4000 said:
well I have same issue and php-fpm takes alot of memory for each download.

for example a downloader with 8 concurrent connections takes about 500MB of RAM.

my server has 16GB ram , which means only 32 people can download with 8 concurrent connections then server is fully loaded !

I thought something was wrong with my PHP-fpm and Nginx configurations till I saw this topic.
If you raise a ticket with access to your site/admin etc, we'll patch in the code.
 

fatality43835

New Member
YetiShare User
Apr 10, 2014
11
0
0
This patch will be included in the next release I presume?
And is there any rough estimate as to when this update is? 2 weeks, 1 month?

Cheers.
 

adam

Administrator
Staff member
Dec 5, 2009
2,046
108
63
fatality43835 said:
This patch will be included in the next release I presume?
And is there any rough estimate as to when this update is? 2 weeks, 1 month?

Cheers.
From above:

These changes are already scheduled for the next code release
Est 3-4 weeks for the next release at the moment.
 

pilot830

New Member
YetiShare User
Jan 22, 2014
242
1
0
this is actually why I use apache because when I switched to nginx it was using a ton of memory and the server load went from 2.xx to 36.xx and higher.. with the same traffic

so whatever you do please dont discontinue support for apache. plenty of us still using it