Learn more about the AAS cluster in the apusicas server configuration series: Use apusic loadbalancer configurations

Source: Internet
Author: User

A cluster is a technology that provides high performance and high availability for applications. Currently, the most common and common Java EE applications are web clusters. More specifically, web clusters solve two problems: Server Load balancer for customer requests and high availability of sessions.

Server Load balancer for customer requests refers to the customer's request dependencyAlgorithmIt is reasonably allocated to multiple Web servers for processing.

Session high availability means that when a web server fails, the client's requests of this Web Server Service are transparently forwarded to other valid Web servers, and the session Status (Session) is still available.

Server Load balancer has always been a matter of love and hate. Reasonable configuration can give full play to the maximum performance of each server and provide the best performance and user experience. If the configuration is unreasonable, it will make you feel overwhelmed and ugly. This kind of things is often rarely successful, often as people are desperate.

Apusic as provides a built-in Server Load balancer and supports third-party server Load balancer, or even hardware Server Load balancer. The following describes how to configure AAS built-in Server Load balancer and third-party server Load balancer.

    • One native advantage of Using AAS's built-in Load balancer is that AAS's built-in distributed session management can ensure the high performance of the cluster and the high availability of sessions. After the server in the cluster fails, session switching is very timely, so there will be no sudden loss of sessions (when the application is no problem.

When apusic loadbalancer is used as the Load balancer, aAs provides three built-in Load Balancing policies:

    1. Random selection policy-Randomly select a server in the cluster to process requests according to the random algorithm.
    2. Round-Robin policy -- select a server in the cluster to process requests in turn.
    3. Weight policy-select the server to process requests according to the weight ratio.

Of course, some other Server Load balancer policies are also supported. You can also expand and add custom Server Load balancer policies.

In general, if the server configuration in the cluster is equivalent, you can use the round-robin policy and combine it with the session-sticky built in AAS to provide better performance; if the configuration of servers in the cluster is significantly different, or even different from the same order of magnitude, you can use a weight policy to configure the proportion of customer request distribution to ensure that each server can achieve a reasonable workload.

Apusic loadbalancer uses the memory replication technology to back up the sessions of each backend server in its own cache. That is, when a backend node finishes processing client requests, it copies the current session to the Server Load balancer. When apusic loadbalance is used, the replication service in sessionservice must be enabled for each node in the cluster.

When apusic loadbalancer is used, because the session is cached in the cache of apusic loadbalancer, when the master node fails, apusic loadbalancer extracts the current session from the cache and takes the session to the next node for processing, ensure the availability of the session.

Generally, we recommend that you create a new Server Load balancer domain, the most independent service application, by using the AAS built-in Server Load balancer. Add a new Server Load balancer domain and use AAS's config. CMD Tool to create a new cluster domain.

Take windows as an example. Open the command line and navigate to % aas_bin %. Enter "config. cmd" in the command line to open the "apusic Domain Configuration Wizard ". For example:

Follow the prompts in the command line and enter the relevant information until the cluster domain is created.

The preceding figure describes the process of creating a cluster domain named "clustertest" with the port number "3333". The created Cluster domain is stored in the disk location tied to other domains. After the cluster domain is created, a new clustertest folder will be created under % apusic_domain_home %, and a loadbalancer will be created under the config directory. CONF file, which indicates that a cluster Domain Based on apusic loadbalancer has been created. In this configuration file, all Server Load balancer configurations are configured on the <service class = "com. apusic. Web. loadbalancer. loadbalancer"/> node.

In the configuration file, the key attribute backendservers defines the servers in the cluster. This is a list of addresses separated by commas (,), including host names and port numbers.

By default, apusic Server Load balancer uses session-sticky and selects available Nodes Based on round robin. Of course, you can also disable session stickiness, as long as you add properties in the loadbalancer service:

 
<Attribute name = "sessionstick" value = "false"/>

You can disable session stickiness.

If you want to use other policies to select nodes, you can add the following attributes:

 
<Attribute name = "balancepolicy" value = "random"/>

The value options include random, round-robin, and loadweight.

Note:When loadweight is selected, you also need to add attributes:

 
<Attribute name = "loadweight" value = "10, 20, 70"/>

To identify the weight value. The value corresponds to the server in the server address list.

In addition, you can expand your load balancing policy by adding attributes as long as you implement the loadbalancepolicy interface:

 
<Attribute name = "balancepolicyclass" value = "userclass"/>

The value is a user-defined class. When two attributes balancepolicy and balancepolicyclass both exist, balancepolicyclass has a higher priority.

To use the session distributed function, the attributes in sessionservice of each apusic server in the cluster are as follows:

 
<Attribute name = "distributable" value = "true"/>

The value must be true. The default value is false.

Note:: Loadbalancer. the loadbalancer configuration in the conf file is similar to apusic in the common application domain. in the conf file, "com. apusic. web. some attributes of WebService can be used in a common sense. Especially when a cluster using apusic loadbalancer encounters garbled code, it can be added under the loadbalancer attribute.

 
<Attribute name = "uriencoding" value = "GBK"/>

This attribute value can solve this problem.Article: Details about how to troubleshoot page garbled characters when using apusic as built-in Load balancer.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.