IPhone learning path based on HTTP persistent connection Server PUSH

Source: Internet
Author: User

IPhoneLearning path based onHTTPPersistent connectionServer PUSHThis article focuses on persistent connections.Server PUSHLet's look at the content.

Information about server push implementation

There is a good article "Comet:" server push "Technology Based on HTTP persistent connections. The article mentions the actual application requirements of Comet:

Monitoring System: Background hardware hot swapping, LED, temperature, and voltage changes;

Instant Messaging System: other users log on and send messages;

Instant quotation system: the background database content changes;

Multiple technologies are also mentioned to implement server push.

I agree with this now and introduce considerations for selection, such as the server's support for long-polling. Currently, the main concern is:

If the data push frequency is not high and the concurrency pressure is low, you can use the AJAX-based long-polling method to implement it easily. Nginx has a Module that supports long-polling and may later support Streaming. Long-polling requests again after each response.

If the data changes rapidly and you want to focus on pushing, you can use streaming Based on Iframe and htmlfile. Here is a good introduction. We also introduced some Server implementations such as APE, which should be selected based on the actual situation. For example, APE is implemented in C, and I use java. For me, it is not easy to extend basic javascript, and the extended performance and reliability functions can be tested. For me, I really want to go through port 80, this is a full range of features I have found, and the official saying that it supports 100 K + concurrency, but there are currently few materials, which means there are not many people to use ).

APE1.0 is mainly about long-polling. The XHRStreaming method is not applicable to IE. In contrast, streamHub streams use the write <script> label to implement cross-browser streaming. Don't mention those that are not open-source. python is not familiar with it. Jetty 6 and Tomcat 6 already support Comet. Generally, they can be satisfied. If concurrency is too large, you have to choose between them. Some people use netty to implement it themselves, more than 0.1 million supported. If you want to write the server on your own, you can see that this is implemented using xsocket.

2010.5 supplement: In the past, there was no clear concept about persistent connections and http persistent connections. In my mind, I always thought about mixing requests and tcp connections. In the long-polling mode, a request and data return response can be seen in firebug, and then the request is sent again, but both are servers with the same tcp connection supporting http1.1 ). As with streamHub, we can see that a response data is continuously increasing, and the content of this response data can be changed through other requests. In the past, we mistakenly thought that such a response is the same connection, and long-polling will re-establish a tcp connection.

For performance or other reasons, some applications are suitable for socket. The B/S structure client can use flash, and later HTML5 is also a good choice. As mentioned in this article:

The self-implemented server usually has performance and scalability problems, so it requires a lot of development effort to implement all the functions. Hemlock is connected to the XMPP Server through flash. Because XMPP Server (such as openfire and ejabberd) itself supports multiple servers, the default version can support concurrency of up to 100,000. If it is slightly optimized, at the same time, supporting millions of users will not be too problematic.

Openfire open source, based on mina implementation like java code can also look at red5 or http://code.google.com/p/gfs-server)

Add several open-source projects based on netty:

Http://openr66.free.fr/GoldenGateFTP.html

Http://code.google.com/p/jmemcache-daemon/

Http://kevwil.github.com/aspen/

Http://code.google.com/p/sensei-search/

(We have seen that the single-host 2*4 core 16 GB of Data achieves nearly 0.5 million online connections, and processes nearly 0.1 million requests per second. The c implementation, kernel, and NIC are all optimized; the highest level in java is Using Netty we have comet running on 100.000 + open connections-this uses some GB of memory and 20% of CPU on a quad core server. one quad-core server with over 0.1 million connections)

Summary: detailed explanation is based onHTTPPersistent connectionServer PUSHI hope this article will help you!

Related Article

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.