GAE Java Application Performance Optimization __java

Source: Internet
Author: User
Tags memory usage java web
GAE Java Application Performance Optimization

Reprint please retain the author information:

Author: 88250

Date: February 8, 2011

This article is the author of the development of GAE application performance optimization experience, mainly from the framework, caching, asynchronous calls, and so on how to perform high-performance gae application design and optimization.

ToC

Using Memcache for caching

HTML page

Data query Results

Memcache Use attention

Reduce memory usage

Try to avoid using frames

No State design

Asynchronous APIs

Other

Static resources

Entity groups

Domain Name resolution

Implementation logic

Resources use Memcache for caching

Caching is primarily used to increase response speed. HTML Page

The page can be divided according to the function of the cache, please refer to: Application memcached improve site performance-reduce read from the database and data sources.

Of course, you can also cache the entire page, simplifying caching and template processing logic. Data Query Results

If you are using GAE Datastoreservice directly to query data, it is necessary to cache query results: Single entity
An entity that queries based on a unique identity. Collection Entities
Entities that are queried based on the combined query criteria, such as paging results. Memcache Use note to invoke Gae Memcache also consumes a certain amount of CPU (requires serialization/deserialization) using the Gae Memcaheservice#clearall () method clears cache reduction for all namespaces Memory Usage

The main purpose of reducing memory usage is to make full use of limited Memcache service and reduce instance startup time. try to avoid using frames

While some popular Java Web frameworks (Spring, Struts, play!, etc) can be run on Gae at the moment, if you want to use Gae as freely as possible,

It's best not to use an existing framework, because most frameworks: not specifically designed for GAE the comparison consumes memory will prolong startup time

In addition, there is no discussion about the pros and cons of JSP and other template engines. Currently tested without page buffering, Freemarker and JSP performance is very close. No State design

Stateful design is compared to eating memory, the server is best to use less stateful model, unless you want to deal with complex business logic (such as multi-step form, advanced search). Asynchronous APIs

GAE provides an asynchronous version of APIs such as data access, HTTP requests, and so on. Note, however, that Query in Gae/j (1.4.0) currently has no asynchronous APIs
Use Preparedquery.asiterable () and Preparedquery.asiterator () on Asyncdatastoreservice or Datastoreservice ()
Effect, is called on the return, the iteration is really to get data blocking (sync) point
In the code block after the asynchronous APIs call, you should pay attention to which point to synchronize, and premature synchronization will reduce the advantage of asynchronous APIs. Invoking the asynchronous APIs consumes the same quota as invoking the synchronization APIs
other Static Resources

Carefully configure the <static-files> elements in Appengine-web.xml, which will be retrieved from a separate Google server, cache, and not occupy

Application server quotas. Entity Groups

An entity group is an entity set that is logically related and stored in the same GAE cloud storage area. Transaction operations can only be done for entities of the same entity group.

Entity groups have a certain impact on performance (not yet proven how large the impact is), but try to keep the entity groups minimized. Domain Name Resolution

GAE Two-level domain name (*.appspot.com) in the domestic access is very unstable, so it is best to bind their own domain name.

However, when binding domain names need to configure GHS IP, currently in the country has no IP available. Further, you need to configure the reverse proxy to make the request agent.

It is necessary to select a fast and stable reverse proxy after service-side performance optimization. Otherwise, the painstaking service-side optimization reduces the processing time of hundreds of MS,

The results are all spent on routing, dropping packets:-(

If the free reverse proxy is really not able to meet the performance needs, you can only make a pay, or wait until GHS available .... implementation Logic

In addition, the current GAE to the free CPU quota less, so optimize the implementation of logic to reduce the CPU, the use of APIs is also very critical.

Write code should always pay attention to the logic of the code is concise enough, can be obtained at a time of the parameters are not repeated acquisition, obtained in the form of method parameters to pass. reference materials App Engine Java Overview Best Practices for writing scalable applications Gae SDK Javadoc gae data Storage-Transaction Gae/java application Framework--b3lo G Latke

This article is the use of B3log Solo from the simple design of the art of the synchronization of the release of the original address: http://88250.b3log.org/gae-java-performance-optimization.html

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.