High performance, highly concurrent

Source: Internet
Author: User
Tags bulk insert redis server

1. Load balancing, plus server offload
1) nginx do load server, distribution processing request, Ip_hash according to IP location server, prevent session not sharing processing.
2. Optimize your code as much as possible
1) including common writing, for loop variables and so on, online a lot of information.
2) consume resources and occupy a lot of memory, have to deal with batch processing, such as batch processing TXT documents, if the TXT document is larger than 1w, Apache ftp If a load, the inevitable memory overflow, must be batch processing, one load 1000 or 5000 depending on the situation, It is best to use multithreading, such as reading txt and processing txt, reading thread pool solution, Countdownlatch class processing thread pool to do the order of tasks.
3) run out of resources in time to close, to read files and connections and sockets and so on
4) Processing httpclient request, request time wait time and so on.
3. Reduce access to the database, preferably bulk INSERT.
1) Start the thread processing queue when the system starts, and if you need to insert SQL, put SQL into the queue and the threads process the SQL at timed time.
4. Cache, increase cache, increase access speed.
1) memcached supports the most languages and supports only Key-value
2) Redis has the best support for Java and has more support types than memcached.
5. Cache clusters solve large-scale access requests, master-slave replication generally small-medium-sized projects can be solved.
1) Large system projects can be clustered with both memcached and Redis
2) I have only used Redis master-slave replication, this generally can solve most problems, just write a redis server, other servers automatically replicate, so you can access the server cache data.
6. Current limit, random access jumps to the promotion page.
1) Current limit, there is no way to restrict access to the number of concurrent requests to solve a lot.
7. High Efficiency for database access
1) Jndi and DRUID,BENCOP Select the appropriate connection pool, based on experience to deal with it.
8. Using queues, some operations can be resolved using multithreading
1) ACTIVEMQ can process messages asynchronously or use the JDK5 thread pool itself.
2) Dubbox do not know how to asynchronous processing, I need to write the demo, currently not tested.
9. Layering, separating, distributing
1) I have done three types of project development, one is to build a lot of Java engineering, compiled into the Web project, not add a module to build a project, disadvantage if using a module is cumbersome.
10. Asynchronously, using a queue, the request does not have to wait until the response can be returned, the queue processes these requests!
11. High performance, programmer from cache, load balancer, queue processing messages and so on.
12. High concurrency, web-side page-style picture storage server, preferably in load-balanced server, reduce the impact of network transmission
1) Web-side css,js, pictures and so on to Nginx, reduce network transmission overhead, the best way to handle
2) Reduce HTTP requests, each request is cost-performance, unnecessary requests can be reduced, it is better to prepare the data, a request to take care of


get ""

High performance, highly concurrent

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.