1

I have a cpanel VPS in one datacenter (linode), where i have a bunch of client's accounts, i want to balance loads using 2 additional VPS's in the same datacenter connected with private IP's.

I was thinking of setting this for balancing loads:

VPS 1: Cpanel, mail server, Apache (Proxy). Get requests, public IP.
VPS 2 : Mysql.
VPS 3: Tomcat.

Right now my priority is setting the VPS 3.

Cpanel architecture loads Java modules through apache loading including in the virtual host definition a mod_jk, i was thinking of changing the servlet to the tomcat VPS, and changing its location to something like:

DocumentRoot IP_OF_VPS:/home/didactac/public_html

How ever i'm not sure if this will wok !

Here is a virtual host in apache:

<VirtualHost 173.230.130.64:80>
    ServerName danielakosanstore.com
    ServerAlias www.danielakosanstore.com
    DocumentRoot /home/danielak/public_html
    ServerAdmin [email protected]
    UseCanonicalName Off
    CustomLog /usr/local/apache/domlogs/danielakosanstore.com combined
    CustomLog /usr/local/apache/domlogs/danielakosanstore.com-bytes_log "%{%s}t %I .\n%{%s}t %O ."
    ## User danielak # Needed for Cpanel::ApacheConf
    <IfModule mod_suphp.c>
        suPHP_UserGroup danielak danielak
    </IfModule>
    <IfModule !mod_disable_suexec.c>
        SuexecUserGroup danielak danielak
    </IfModule>
    ScriptAlias /cgi-bin/ /home/danielak/public_html/cgi-bin/

    Include "/usr/local/apache/conf/userdata/*.conf"
    Include "/usr/local/apache/conf/userdata/*.owner-root"
    Include "/usr/local/apache/conf/userdata/std/*.conf"
    Include "/usr/local/apache/conf/userdata/std/*.owner-root"
    Include "/usr/local/apache/conf/userdata/std/2/*.conf"
    Include "/usr/local/apache/conf/userdata/std/2/*.owner-root"
    Include "/usr/local/apache/conf/userdata/std/2/danielak/*.conf"
    Include "/usr/local/apache/conf/userdata/std/2/danielak/danielakosanstore.com/*.conf"

The configuration file included on those last lines, which loads servlets:

</VirtualHost>

<IfModule mod_jk.c>
 JkMount /*.jsp ajp13
 JkMount /* ajp13
 JkUnmount /*.php* ajp13
 JkUnmount /*.cgi ajp13
 JkUnmount /*.shtm* ajp13
 JkUnmount /*.pl ajp13
 JkMount /servlet/* ajp13
 JkMount /servlets/* ajp13
</IfModule>

What do you guys think ? i need to be able to add a bunch of clients-accounts-servlets, or delete them automatically

Thank you very much!

UPDATE, Improving my question:

This section is intended on given additional detail about the question base on the feedback and questions of quanta in the comments:

quanta: What do you want to load balancing when you have only one Tomcat instance on VPS3? What does "add a bunch of clients-accounts-servlets" mean?
Answer: Probably i did not use the term load balancing the right way, you see, i install one java application per account, an account is a website that runs based on this java app, for each website there is a linux user, and a virtual host in http.cnf (apache) and one virtual host in the server.xml. Apache acts as a proxy, for tomcat on the current VPS. Right now there is only one VPS. What i need is this same setup but running tomcat in a different machine. This way if tomcat's machine's memory does not hold up, i can set a new tomcat machine, put the new client there. To that i called load balancing. But i get the feeling im not using the term the right way.

2
  • Could you please explain your situation a litle more? What do you want to load balancing when you have only one Tomcat instance on VPS3? What does "add a bunch of clients-accounts-servlets" mean?
    – quanta
    Sep 3, 2011 at 0:45
  • Probably i did not use the term load balancing the right way, i install one java application per account, an account is a website that runs based on this java app, for each website there is a linux user, and a virtual host in http.cnf (apache) and one virtual host in the server.xml. Apache acts as a proxy, for tomcat on the current VPS. Right now there is only one VPS. What i need is this same setup but running tomcat in a different machine. This way if tomcat's machine's memory does not hold up, i can set a new tomcat machine, put the new client there. To that i called load balancing.
    – Ernest
    Sep 3, 2011 at 21:42

1 Answer 1

1

I install one java application per account, an account is a website that runs based on this java app, for each website there is a linux user, and a virtual host in http.cnf (apache) and one virtual host in the server.xml. Apache acts as a proxy, for tomcat on the current VPS. Right now there is only one VPS. What i need is this same setup but running tomcat in a different machine.

Sure, you can do it by changing the worker.<worker_name>.host to the IP address of backend Tomcat instance in workers.properties, something like this:

worker.worker1.host=backend.Tomcat's.IP.address

Can i link a specific client (website, virtual host, account... the same in this case) to a specific worker

Yes, you can. Put the JkMount into VirtualHost section:

<VirtualHost *:80>
    ServerName  ...
    ServerAdmin ...

    JkMount /*.jsp ajp13
    JkMount /* ajp13
    ...
</VirtualHost>
1
  • Thanks man! this is great! i read the workes doc in tomcat.apache.org wiki and it feels so right!. How ever i don´t understand something. Can i link a specific client (website, virtual host, account... the same in this case) to a specific worker, or im a miss understanding something ? thank you its been a great help already
    – Ernest
    Sep 6, 2011 at 2:56

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .