When we create a project
and feel that a particular service is going to be used very frequently and want
to divide total load into different server then we normally create clone of
that server so that half-half load can be divided. If we have 2 different
server for the same process and want to divide same request to both server then
in ESB side we can configure load balancing so that every time request will go
to different -2 node one by one.
To configure load balance
in WSO2 ESB, you need to go through below steps.
Go to the endpoints and
click on Add Endpoint tab
(highlighted in yellow)
- Endpoint Name: You will see below screen in which you need to give endpoint name it must be a unique name in whole synapse code.
- Algorithm: There is only one algorithm as of now and it is selected by default.
- Session Management: In session management, you can select one of the below values.
- None: No session management is used.
- Transport: session is maintained on http level by cookies.
- SOAP: Session is maintained by SOAP session.
- Client Id: Id is sent to maintained session.
- Session Timeout: you can provide session timeout in milliseconds.
Once you complete the
above screen, simply click on add endpoints to add endpoint.
In above screen we have
added 2 endpoints so that request can go to each node one by one. In this you
can select Address, WSDL, Failover Group and Load balance group.
So for each endpoint I
have given Name and its address, click on ‘Save’ button to save configurations.
Synapse
Code:
<endpoint name="DSS_EmployeeDetailDataService_EPR2">
<loadbalance policy="roundRobin" failover="false">
<endpoint name="DSS_EmployeeDetailDataService_EPR_1">
<address uri="http://localhost:8280/services/DSS_EmployeeDetailDataServiceProxy">
<timeout>
<duration>10000</duration>
<responseAction>fault</responseAction>
</timeout>
<suspendOnFailure>
<errorCodes>101500,101501,101506,101507,101508</errorCodes>
<progressionFactor>0.0</progressionFactor>
</suspendOnFailure>
<markForSuspension>
<errorCodes>101504,101505</errorCodes>
<retriesBeforeSuspension>0</retriesBeforeSuspension>
</markForSuspension>
</address>
</endpoint>
<endpoint name="DSS_EmployeeDetailDataService_EPR_2">
<address uri="http://localhost:8281/services/DSS_EmployeeDetailDataServiceProxy">
<timeout>
<duration>10000</duration>
<responseAction>fault</responseAction>
</timeout>
<suspendOnFailure>
<errorCodes>101500,101501,101506,101507,101508</errorCodes>
<progressionFactor>0.0</progressionFactor>
</suspendOnFailure>
<markForSuspension>
<errorCodes>101504,101505</errorCodes>
<retriesBeforeSuspension>0</retriesBeforeSuspension>
</markForSuspension>
</address>
</endpoint>
</loadbalance>
</endpoint>
No comments:
Post a Comment