DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports Events Over 2 million developers have joined DZone. Join Today! Thanks for visiting DZone today,
Edit Profile Manage Email Subscriptions Moderation Admin Console How to Post to DZone Article Submission Guidelines
View Profile
Sign Out
Refcards
Trend Reports
Events
Zones
Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Partner Zones AWS Cloud
by AWS Developer Relations
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Partner Zones
AWS Cloud
by AWS Developer Relations
  1. DZone
  2. Software Design and Architecture
  3. Performance
  4. Load Balancing Using web.xml

Load Balancing Using web.xml

Testing an app's performance in the prod environment may require creating a replica, which may not be feasible. See how to create a load balancing app with just web.xml.

Piyush Singh user avatar by
Piyush Singh
·
Apr. 25, 17 · Tutorial
Like (8)
Save
Tweet
Share
7.75K Views

Join the DZone community and get the full member experience.

Join For Free

If you are wondering how you can test the performance of your newly developed application in a production environment, then probably you have to create a replica — which is not feasible in most of the cases. By following some simple tricks, you can create a production-like environment in your dev set-up only. A major restriction is the SSL, networking, load balancing, and clustering of the server for creating the replica of the production environment. Today, I would be telling you how to create a load balancing application in your dev environment using just web.xml.

Here's my reference from the Oracle site.

Create a dynamic web project in your IDE and place the below code in web.xml:

<web-app>
	<servlet>
		<servlet-name>HttpClusterServlet</servlet-name>
		<servlet-class>weblogic.servlet.proxy.HttpClusterServlet</servlet-class>
		<init-param>
			<param-name>WebLogicCluster</param-name>
			<param-value>localhost:7002|localhost:7003</param-value>
		</init-param>
		<init-param>
			<param-name>DebugConfigInfo</param-name>
			<param-value>ON</param-value>
		</init-param>
	</servlet>
	<servlet-mapping>
		<servlet-name>HttpClusterServlet</servlet-name>
		<url-pattern>/</url-pattern>
	</servlet-mapping>
	<servlet-mapping>
		<servlet-name>HttpClusterServlet</servlet-name>
		<url-pattern>*.jsp</url-pattern>
	</servlet-mapping>
	<servlet-mapping>
		<servlet-name>HttpClusterServlet</servlet-name>
		<url-pattern>*.htm</url-pattern>
	</servlet-mapping>
	<servlet-mapping>
		<servlet-name>HttpClusterServlet</servlet-name>
		<url-pattern>*.html</url-pattern>
	</servlet-mapping>
</web-app>

Creat the WAR and deploy it into a new managed server that is not pointing to any of the clusters. Add the URLs of the managed servers for which you wish to use for the load balancing: <param-value>localhost:7002|localhost:7003</param-value>.

Access your application with the port number of the deployed load balancing application and you will get the required result. And you're done!

Load balancing (computing)

Opinions expressed by DZone contributors are their own.

Popular on DZone

  • Using GPT-3 in Our Applications
  • 3 Main Pillars in ReactJS
  • 7 Most Sought-After Front-End Frameworks for Web Developers
  • Build an Automated Testing Pipeline With GitLab CI/CD and Selenium Grid

Comments

Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 600 Park Offices Drive
  • Suite 300
  • Durham, NC 27709
  • support@dzone.com
  • +1 (919) 678-0300

Let's be friends: