- 1 -
HTTP-based Real-time Information Communication
Method in the High Load Situation
Wang Zhongwei, Song Zheng**
(State Key Laboratory of Networking and Switching Technology, Beijing University of Posts & 5
Telecommunications, Beijing 100876)
Abstract: This thesis puts forward a real-time communication method which transmits information
between the clients and the servers. The method is applied to access servers with high concurrency of a
large number of clients and highly loaded servers with a high demand on the real-time communication.
Integrated with the advantages of three real-time communication technologies and based on the HTTP 10
protocol, this method connects long links and short links, applies asynchronous polling to clients and
sets up cache requesting queue on serves. It’s been tested that this method can balance the various
performance indicators well in the above-mentioned.
Keywords: Real-time communication; HTTP; Asynchronous polling; Long connection
15
0 Introduction
In the Internet technology, the demand of real-time information transmission becomes
extremely extensive, such as stock instant quotation, work together on the internet, chatting online,
personal homepage or E-mail data gets timely, etc. But at the same time, in the system that
contains large number of users, each center server will deal with a large number of client access 20
frequently request, which raises great challenge to server processing and network transmission
ability. How to give consideration to the real-time and server processing capacity and effective use
of network bandwidth is particularly critical.
The HTTP protocol is the current network transmission widely used application layer
protocol. At present, there are three methods to realize the real-time information transmission 25
based on HTTP: client synchronous refresh, AJAX asynchronous transmission and long connect to
the server push mechanism; these three kinds of technology have their respective advantages and
application situation.
This paper integrated their respective advantages of the three real-time transmission
technologies, based on HTTP protocol, creates a new real-time information transmission method 30
between the client and the server, This method adapted to the above mentioned situation that
server high load and high concurrency and high demand for real-time application, which can better
balance various performance indicators, and reduce bottleneck.
1 Three real-time information transmission technology based on
HTTP that existed 35
Client real-time refresh
This technique sets timer in the client which sends a HTTP connection request to server every
once in a while. After receives request, the server processes and response to the request, returns
the result back to the client and disconnect the link. As this process, the client repeats requests.
But the shortcoming of this method is very obvious. First of all, the delay cannot avoid, it 40
cannot be able to be completely timeliness. If we set polling interval for 5 s, then the content
updated maximum delay will be 5 s [1]. Secondly, in order to pursue the timeliness, frequent
refresh and polling will take up too much network bandwidth. When the client number is too much,
- 2 -
this kind of method is almost disguised distributed attack of service denial. Another problem is
that due to the client request is synchronous, which leads to the clients waiting for return from 45
server after requested. So it reduces the efficiency of the client.
Based on AJAX asynchronous transmission
The working principle of AJAX is adding a layer between user and server, which makes the
user operation and server response asynchronies. Not all user requests are submitted to the server,
like some data validation and data processing will be given Ajax engine to do. Only surely need to 50
read data from the server then the Ajax engine to submit user’s request to the server.
The client use JavaScript language, through the DOM access request parameter information,
and use XMLHttpRequest object to communicate asynchronously with server. After server
processes request, return to normal text or XML. Browser uses the JavaScript processing text or
analytic XML, and update related UI through the DOM[2]. The above technical realization, makes 55
AJAX has the following advantages: Firstly, asynchronous mode improves the client efficiency;
secondly, the optimization between the client and the server of the transmission and reduce
unnecessary data round, reduces the bandwidth; thirdly, Ajax engine operates in the client, takes a
part of originally from the server jobs, so as to reduce the load on the servers.
But at the same time, real-time and network bandwidth occupancy still failed to get the basic 60
solution to AJAX.
Long connect and the server push mechanism
In order to thoroughly realize the server to the client information real-time transmission, it
appeared long connection communication mode based on HTTP. Once the connection between
client and server has been established, the server maintains the link and doesn’t interrupted, in 65
which can transmit real-time information.
The reality of long connection mechanism usually by two ways:
(1) Based on the long polling method: the server end will jam request until the data transfer
or overtime to return. After the client finishes processing information that server returned, it will
send request and establish link again. 70
(2) Based on the flow method: “iframe” is a HTML tag, which embeds a hidden frame in the
HTML page, then sets SRC attribute of implicit frame for a long connection request. The server
can send to the client data continuously[3].
Long connect and the server push mechanism can be a solution to real-time problem, but at
the same time it brings a big problem of the server load. Because maintain every connection will 75
cost quite a part of the server resources, when the number of connecting client is very large at the
same time, it will be more than server load and damage the server's overall performance.
2 Based on HTTP asynchronous polling and request cache
communication mechanism design
Overall framework design 80
This communication mechanism overall frame and the information communication process is
shown as shown in figure 1, which shows the process of client two continuous request for server
data. In communications, it realizes asynchronous between user activities and request to server by
joining the function module of polling engine in client. The user gives requests needed to polling
engine and continues to other activities. The task of sending requests to server completely is 85
controlled by polling engine. When polling engine receives returns from server, and then gives
- 3 -
中国科技论文在线
them to user. When polling engine finishes a request, it will not follow the next request, but will
wait for a period of time (polling cycle)[4]. That is not only to reduce the pressure of high load
server, but also for offline waiting for the server processing results. On the other side, it reduces
the number of concurrent server connection. The determination of polling cycle will be detailed 90
researched in .
In server, because the load is high and data processing is relatively complex, it may not be
able to immediately get processing results that user needs; In this case, the server will maintain the
link for a period of time (timeout). If there are results returned to the client this period of time,
then return and disconnect, or timeout disconnect. For the client request not successful returned, 95
the server will receive the request again. About the server internal specific implementation, we
will discuss in section . Timeout settings will be analyzed in section .
Fig. 1 Overall design and event communication procedures
The server structure design 100
After the server receives the client request, processes as figure 2 shows. First of all the
request must pass a server gateway, which can recognize a new event or that had been requested.
If it is the new request event, it will be transmitted to the server for real-time processing along
road (1). In the period of Timeout, if the server can get processing results, the road (2) will be used
to transfer the results back to the server gateway and transfer message back to the client. In this 105
process, the link between client and the server has been held all the time. If the server doesn't get
processing results in Timeout, message also will be to passed through road (2) to tell the server
gateway has not get processing results. The server gateway also sends this message to client and
interrupts the link. At the same time, the request that has not been deal with will be put in the
request queue through road (3). Server will continue to extract request from request queue, and 110
- 4 -
中国科技论文在线
processing. If get return result, the server match it to request queue, and put the processing results
into cache.
If the client request for the first time didn’t get a response result, the same request for the
second time or in the future polling will find result from cache through the road (6). If processing
results corresponding to the request is existed in the cache, it will be directly read through (5), 115
return to the client, and disconnect; if it does not yet exist processing results, also tell the client,
and disconnect, waiting for the same request polling again.
Fig. 2 Structure of server
Such structure design in server side, combine with long connection and short connection. 120
When a request first arrived at server gateway, links will keep Timeout to wait for processing
complete and return to the results. After this period of time long connection, it can ensure that
most of the processing results can be real-time returns and meet the real time requirements[5]. But
if the server is heavy-load or we need to wait for server status change information, keeping long
connection will cost much server resources. So polling will be more appropriate in this condition. 125
When the same request second or late arriving server gateway, the short link way will be used to
search results in cache directly.
Communication protocol design
When the client sends request to server, the server gateway need to recognize this is the new
request or old, and can match the processing results with that in cache. Because the method in this 130
paper is based on HTTP, we can’t modify HTTP protocol header. We can only add some fields as
showed in table 1 to satisfy the application.
Table 1 New field added in protocol
Fieldname Meaning
P_time Time stamping (client provide)
P_id Session id (server provide)
P_first mark for first visit
135
In order to mark each client request, it need client and server mark the request together. The
client takes the timestamp as making, which will be put at p_time field. When the server receives
request, it put content in p_id, which includes server thread id that responsible for processing the
- 5 -
中国科技论文在线
request and request count n that the same thread processed. Each server processing thread will
have a treated request count, the count n from 1 to a large numerical cycle. Both sides fill in the 140
p_time and p_id, which makes both sides can identify the same request, so as to realize the client
polling and server search results in the cache according to the request.
In addition, the server gateway also needs to know whether the request received is the first
time arrived, so as to carry on the different treatment. So set p_first field which is filled by the
client and server directly read. 145
3 Setup polling cycle and timeout
As previously mentioned this system has great advantage under the condition of high in
server load and having the real-time needs. This advantage is based on combination of long and
short connection, which needs to choice effective connection time. We needs to set some 150
parameters based on the condition of client、network and server. Below is the polling cycle and
timeout value analysis.
Setup polling cycle
As to the client sending requests, firstly, user activity part according to operation produces
request; however, sending request to server is completely controlled by polling engine. There are 155
two queues in polling engine. Queue 1 deposits the new request that user activities create, and
queue 2 deposits that has not get returns from server. In order to ensure the real-time to new
request, queue 1 has higher priority than queue 2.
After polling engine receives request from user activities part, puts the request into queue 1,
labels timestamp in p_time field and sets p_first field true. After that, if the client does not 160
maintain long connection with the server, then immediately send the request.
When queue 2 sends requests, we take the strategy of first in first out and sending all once.
Polling cycle was actually aimed at interval when send the request in queue 2, determine its length
of time T between twice sending, which is shown in figure 1 of the polling cycle. In order to
determine polling cycle T, we need to consider the following factors: (1) the interval (T) between 165
present moment and queue 2 request last sending; (2) the length (l) of current queue 2; (3) the
request frequency (p) of average queue 2.
The average frequency (p) request for queue 2, we can accord the following formula:
l
n
p
l
i
i∑
== 1 (1)
170
In formula, L represents the queue length, which is the number of queue 2 requests; said
the time of each request has sent to the server[6].
We can analyze the T based on the above amount. Firstly, when t is longer, there will be
greater demand to immediately send request. Secondly, the longer of the length of queue2, the
cycle of sending should be shorter. Thirdly, the more average request time in queue 2, explain this 175
batch request processing time to grow more, should extend the polling cycle. From the above
analysis, we can get the following formula:
ltpaT 321 ηηη −−+= (2)
180
- 6 -
中国科技论文在线
In formula, a is the initial setting polling cycle value, in order to show the relations amount
three variable p, t and l, we set η1,η2,η3 positive. And the determine of a,η1,η2,η3 need
according to the specific server performance task quantity and client quantity. In the
experimental verification will give specific value.
Setup timeout 185
Timeout refers to the time that server maintain links when new request comes. In order to
insure real-time well, most of the request must be able to obtain return a result in the timeout, so
the length of the timeout need according to statistics method to determine.
Due to the randomness of the client request, the server response time satisfies normal
distribution. Probability density formula of normal distribution is: 190
2
2
2
)(
2
1)( σ
μ
σπ
−−=
x
exf (3)
When the server receives request, it processes time statistics continuously and adjusts the
Timeout. And it gradually formed the normal distribution curve of the processing time. In figure 3, 195
X axis means the processing time of request, f(x) means the probability of corresponding time.
After format this curves, we get x=μ+σas Timeout value[7]. As figure 3 showed, the probability
of request getting response results could be as high as % before timeout, which can satisfy
most of the real-time requests, and few requests that can’t get corresponding can timely return and
disconnect. 200
4 Evaluation results
This chapter analyzes framework performance designed in this paper. Compare to other three
communication mode, to show improvement in performance. Specific experimental environment
and experimental process is as follows:
Under the same local area network environment, we use Grinder as tool to respectively test 205
the real-time refresh、Ajax polling mode、long connection and the communication mechanism of
this paper to compare relative performance parameter. When testing, the number of simulation
online clients is 500 and send requests at the same time. Test environment is: client configuration:
Windows XP, Server configuration: enterprise
edition; Get the following test results: 210
Table 2 Performance test results
Test scheme The time cost when
all the request
returned(s)
Server CPU
utilization (%)
All request
frequency (times)
Real-time refresh 783
Ajax asynchronous 776
Long connection 504
Asynchronous polling and
cache the request
563
We can find the results from the above analysis: (1) real-time refresh and Ajax asynchronous
mode performance parameter is close, and the reason is the main advantages of Ajax is reflected in 215
client running asynchronous.(2) the first term in this table shows the real-time situation. Long
- 7 -
中国科技论文在线
connection effect optimal and the mechanism in this paper close the effect. (3)The second term
can reflect the server load. Two kinds in front effect well and long connection way increases
server load. (4) All request number represents the network bandwidth occupancy, the mechanism
of this effect is also better. 220
5 Conclusion
In the B/S network communication, and in the situation of high server load、high concurrency
and high requirements of real-time, the three performance of real time、network bandwidth and
server load will gradually become opposite to each other. The existing three schemes can only
well solve one or two problem, and often the performance not to be well solved becomes the 225
bottleneck for application.
The mechanism designed in this paper integrated the existing three kinds of information
real-time transmission technology scheme. Combining with the long connection and short
connection, we analyze to get appropriate parameter. Through the experiment testing, this
mechanism embodies great advantage. 230
References
[1] LI Xiu,LI Wei. Polling algorithm based on traffic burst characteristics of broadband wireless access systems[D].
Jinan: Shandong Economy University, 2011.
[2] Zsolt Saffer, Mikls Telek. Analysisofglobally gated Markovian limited cyclic polling model and its application 235
to IEEE network[D]. Beijing: Budapest University of Technology and Economics, 2010.
[3] Jiangyi, Wangzhaoqing, Caoli. Based on HTTP real-time information transmission method[J]. Computer
engineering and design, 2008, 29(10): 60-64.
[4] Sunqingguo, Zhuwei, Liuhuajun. Survey on Server-Push Technology of Web Applications[J]. Computer
system with virtual, 2008, 20(12): 24-29. 240
[5] , , . Delay Analysis of based Last Mile Wireless Networks[J]. In IEEE
Global Telecommunications Conference(GLOBECOM), 2005, 5(3): 3123-3127.
[6] , , . Delay Analysis and Comparison of OFDM -TDMA and OFDMA under IEEE
QoS Framework[J]. In IEEE Global Telecomm Conf(GLOBECOM), 2006, 1(4): 1-6.
[7] . Analysis of Polling Systems[M]. Boston,USA: MIT Press, 1986. 245
[8] Oh S M , Kim J H. The analysis of the optimal con-tention period for IEEE BWA systems [A].
Proceedings of the 3rd IEEE Intenational Conference on Pervasive Computing and Communication[C].
Washington, USA: IEEE, 2005. 215-219.
基于 HTTP 的高负载情境下实时信息通信方法 250
王中伟,宋峥
(北京邮电大学网络与交换技术国家重点实验室,北京 100876)
摘要:本文提出了一种在客户端与服务器之间的实时信息通信方法,这种方法适用于大量客
户端高并发的访问服务器、服务器负载较高并且对通信实时性有较高要求的情况下。本文的
方法综合了现有的三种实时信息传输技术的优势,基于 HTTP协议,采用长连接与短链接相255
结合的方式,在客户端采用异步轮询,在服务器端设置请求缓存队列。经测试,在上述通信
环境中能够较好的平衡各项性能指标,提高实时信息的通信质量。
关键词:实时通信;HTTP;异步轮询;长连接
中图分类号:
260