使用tomcat进行海量虚拟主机
我正在使用 tomcat 5.5 为超过 100 个站点提供服务(假设 my-gwt-site-1.com 到 my-gwt-site-100.com)。
我的所有站点都使用先前部署的 gwt 应用程序的单个实例,它们之间的唯一区别在于 server.xml 中的“主机”配置部分:
<Host name="my-gwt-site-1.com" appBase="webapps">
<Context path="" reloadable="true" docBase="/my-gwt-app/" debug="1"
unpackWARs="false" autoDeploy="false" xmlValidation="false" xmlNamespaceAware="false" crossContext="true">
<Resource name="jdbc/mysql/db_1" auth="Container" type="javax.sql.DataSource"
initialSize="2" maxActive="50" maxIdle="5"
maxWait="15000" removeAbandoned="true" removeAbandonedTimeout="2"
validationQuery="select now();"
username="root" password="pass" driverClassName="com.mysql.jdbc.Driver"
url="jdbc:mysql://localhost:3306/db_1"
/>
</Context>
&它会在我的所有网站上重复...
<Host name="my-gwt-site-100.com" appBase="webapps">
<Context path="" reloadable="true" docBase="/my-gwt-app/" debug="1"
unpackWARs="false" autoDeploy="false" xmlValidation="false" xmlNamespaceAware="false" crossContext="true">
<Resource name="jdbc/mysql/db_100" auth="Container" type="javax.sql.DataSource"
initialSize="2" maxActive="50" maxIdle="5"
maxWait="15000" removeAbandoned="true" removeAbandonedTimeout="2"
validationQuery="select now();"
username="root" password="pass" driverClassName="com.mysql.jdbc.Driver"
url="jdbc:mysql://localhost:3306/db_100"
/>
</Context>
我这样做的唯一原因是因为我的应用程序需要为每个域使用单独的资源。
当 server.xml 中的“host”部分数量约为 5 时,没有问题,但是当它增长到大约 10 或更多时,tomcat 服务器成功启动,但无法加载我的任何站点(似乎在背景无声!)
我想知道这是在 server.xml 中添加大量“主机”标签的好解决方案还是有更好的方法来做到这一点?请注意,我只想对我的所有网站使用一个代码和单独的数据库。
另一个问题是,一台服务器(配备 2 个 Quand Core CPU 和 4GB RAM)通常可以运行多少个 Java 站点(每个站点大约有 500 个用户和低流量)?
I'm using tomcat 5.5 for serving more that 100 sites(suppose my-gwt-site-1.com to my-gwt-site-100.com).
All of my sites are using a single instance of a previously deployed gwt application, the only deference between them is in their "Host" configuration section in server.xml :
<Host name="my-gwt-site-1.com" appBase="webapps">
<Context path="" reloadable="true" docBase="/my-gwt-app/" debug="1"
unpackWARs="false" autoDeploy="false" xmlValidation="false" xmlNamespaceAware="false" crossContext="true">
<Resource name="jdbc/mysql/db_1" auth="Container" type="javax.sql.DataSource"
initialSize="2" maxActive="50" maxIdle="5"
maxWait="15000" removeAbandoned="true" removeAbandonedTimeout="2"
validationQuery="select now();"
username="root" password="pass" driverClassName="com.mysql.jdbc.Driver"
url="jdbc:mysql://localhost:3306/db_1"
/>
</Context>
& it repats fot all of my sites...
<Host name="my-gwt-site-100.com" appBase="webapps">
<Context path="" reloadable="true" docBase="/my-gwt-app/" debug="1"
unpackWARs="false" autoDeploy="false" xmlValidation="false" xmlNamespaceAware="false" crossContext="true">
<Resource name="jdbc/mysql/db_100" auth="Container" type="javax.sql.DataSource"
initialSize="2" maxActive="50" maxIdle="5"
maxWait="15000" removeAbandoned="true" removeAbandonedTimeout="2"
validationQuery="select now();"
username="root" password="pass" driverClassName="com.mysql.jdbc.Driver"
url="jdbc:mysql://localhost:3306/db_100"
/>
</Context>
the only reason I do this is because my application needs to use the separate resource for every domain.
when number "host" sections in server.xml is about 5, the is no problem, but when it grows up to about 10 or more, the tomcat server starts successfully but it cant load any of my site(seems that it crashes in the background silently!)
I want to know is this a good solution to add a lot of "host" tags in server.xml or there is any better way to do this? Attention that I Just want to use one code with separate databases for all of my sites.
Another question is that how many java sites(each one with about 500 users and low traffic) usually can be run on a single server(with 2 Quand Core CPUs & 4GB of RAM)?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论