RegisterRegister    SearchSearch   ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

AJAX upload progress bar

File sharing script

File mirror script

Newsletter script
increase Perfomance your XfileSharing pro cgi scripts

 
Post new topic   Reply to topic    SibSoft Ltd Forum Index -> XFileSharing Pro
View previous topic :: View next topic  
Author Message
sherayusuf3



Joined: 18 Jan 2009
Posts: 92
Location: Jakarta Indonesia

PostPosted: Jan 20, 2010 3:50 am    Post subject: increase Perfomance your XfileSharing pro cgi scripts Reply with quote

This tutorial shows how to install and use SpeedyCGI (also known as PersistentPerl) on a Debian Etch system. SpeedyCGI is a way to run Perl scripts persistently, which can make them run much more quickly. It keeps the Perl interpreter running, and during subsequent runs, this interpreter is used to handle new executions instead of starting a new Perl interpreter each time.

This document comes without warranty of any kind! I do not issue any guarantee that this will work for you!

1 Preliminary Note

I have tested this on a Debian Etch system (with Apache2 installed) with a virtual host www.example.com (document root: /var/www/web1/web) which is configured to run Perl scripts in the /var/www/web1/cgi-bin directory. The paths used here might differ from your setup, so adjust them where appropriate.

In the following I will show you three different ways of using SpeedyCGI for your Perl scripts.


2 Installing SpeedyCGI


To install SpeedyCGI together with the SpeedyCGI Apache2 module, we simply run:

Code:
apt-get install libapache2-mod-speedycgi speedy-cgi-perl


and restart Apache afterwards:

Code:
/etc/init.d/apache2 force-reload


3 Using SpeedyCGI

First we create a normal "Hello World!" Perl script to see if Perl is working. At the end of the script, we use some special code that is executed only if SpeedyCGI is used. This helps us to determine when we are in "SpeedyCGI mode" and when in normal "Perl mode". I create the script in my cgi-bin directory, /var/www/web1/cgi-bin:

Quote:
vi /var/www/web1/cgi-bin/speedy-test.cgi


Code:
#!/usr/bin/perl

### Your Script Here.  For example:
print "Content-type: text/html\n\n<h1>Hello World!</h1>\n";

##
## Optionally, use the CGI::SpeedyCGI module for various things
##

# See if we are running under SpeedyCGI or not.
if (eval {require CGI::SpeedyCGI} && CGI::SpeedyCGI->i_am_speedy) {
  print "<br>Running under speedy=", CGI::SpeedyCGI->i_am_speedy ? 'yes' : 'no', "\n";
}


We must make the script executable:

Quote:
chmod 755 /var/www/web1/cgi-bin/speedy-test.cgi


(If you are using suExec, you will also have to change the owner and group of the script to match the suExec user and group of this vhost.)

Now we can call that script in a browser (http://www.example.com/cgi-bin/speedy-test.cgi). You should see Hello World!, nothing else:

3.1 Telling Apache To Execute All Perl Scripts Through SpeedyCGI

The first method is to tell Apache that it should execute all Perl scripts through SpeedyCGI if the Perl scripts are in a certain location. We will create an alias /speedy/ that points to our cgi-bin directory, and when we use the /speedy/ address in our browser, the Perl script gets executed by SpeedyCGI, whereas when we use /cgi-bin/, the script is run without SpeedyCGI.
Click here to find out more!

Open the file where your Apache vhost location for www.example.com is located, and add the following lines to it (if you are using ISPConfig, you can simply paste the following lines into the Apache Directives field of the respective vhost):

Code:
Alias /speedy/ /var/www/web1/cgi-bin/
<Location /speedy>
  SetHandler speedycgi-script
  Options ExecCGI
  allow from all
</Location>


Restart Apache afterwards (you don't have to do this if you're using ISPConfig):
Quote:

/etc/init.d/apache2 restart



Then go to http://www.example.com/speedy/speedy-test.cgi, and you should see that the script is now being executed through SpeedyCGI:
Back to top
View user's profile Send private message Visit poster's website Yahoo Messenger
PowerChaos



Joined: 19 Dec 2009
Posts: 440
Location: belguim

PostPosted: Jan 20, 2010 6:19 am    Post subject: Reply with quote

can you give us a bit more explanation why this is better then the normal cgi ??

if i readed it right , then it shal decrease a bit less cpu usage because it use only 1 instance of perl instead XX instances (every request)

but is it stable to ? and does it do something about download speed

basicly i like to know , what good stuff do i have when using this instead the basic ??

what more stuff you have ?? what change to a better side then we have now Very Happy

Thank you
Greets From PowerChaos
Back to top
View user's profile Send private message Send e-mail Visit poster's website MSN Messenger
sherayusuf3



Joined: 18 Jan 2009
Posts: 92
Location: Jakarta Indonesia

PostPosted: Jan 25, 2010 4:56 am    Post subject: Reply with quote

SpeedyCGI is a way to run perl scripts persistently, which can make them run much more quickly. A script can be made to to run persistently by changing the interpreter line at the top of the script from:

#!/usr/bin/perl

to

#!/usr/bin/speedy

After the script is initially run, instead of exiting, the perl interpreter is kept running. During subsequent runs, this interpreter is used to handle new executions instead of starting a new perl interpreter each time. A very fast frontend program, written in C, is executed for each request. This fast frontend then contacts the persistent Perl process, which is usually already running, to do the work and return the results.

By default each perl script runs in its own Unix process, so one perl script can't interfere with another. Command line options can also be used to deal with programs that have memory leaks or other problems that might keep them from otherwise running persistently.

SpeedyCGI can be used to speed up perl CGI scripts. It conforms to the CGI specification, and does not run perl code inside the web server. Since the perl interpreter runs outside the web server, it can't cause problems for the web server itself.

SpeedyCGI also provides an Apache module so that under the Apache web server, scripts can be run without the overhead of doing a fork/exec for each request. With this module a small amount of frontend code is run within the web server - the perl interpreters still run outside the server.

SpeedyCGI and PersistentPerl are currently both names for the same code. SpeedyCGI was the original name, but because people weren't sure what it did, the name PersistentPerl was picked as an alias. At some point SpeedyCGI will be replaced by PersistentPerl, or become a sub-class of PersistentPerl to avoid always having two distributions.

another info about my tweak follow this link
http://www.sibsoft.net/forum/alternative-web-server-beside-apache-t986-15.html?highlight=nginx
Back to top
View user's profile Send private message Visit poster's website Yahoo Messenger
komi



Joined: 27 Nov 2009
Posts: 159

PostPosted: Jan 25, 2010 7:25 am    Post subject: Reply with quote

Did you try this with XFS?
Back to top
View user's profile Send private message
PilgrimX182



Joined: 22 Mar 2006
Posts: 2106
Location: UFO Lab

PostPosted: Jan 26, 2010 1:11 pm    Post subject: Reply with quote

Just tried it on XFS and it works pretty buggy. Loosing login session somehow.
And it's latest version is from 2003 Smile
Back to top
View user's profile Send private message Visit poster's website
komi



Joined: 27 Nov 2009
Posts: 159

PostPosted: Jan 26, 2010 3:34 pm    Post subject: Reply with quote

Thanks for letting us know.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    SibSoft Ltd Forum Index -> XFileSharing Pro All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

Powered by phpBB © 2001, 2005 phpBB Group