Implementation of ASP server without flush push technology

Source: Internet
Author: User
Tags command line flush resource thread cpu usage
Server | refresh | No refresh about PUSH technology
-----------------------------
Reprint please indicate the source: a crane. net_www.1he.net

Client PULL (clients pull technology)
In general, chat rooms are constantly refreshed to display the latest information about the server, that is, the so-called client PULL (clients pull technology) client PULL must continuously establish the connection, refresh the information, disconnect, which is inefficient and slow. (If you speed up, frequent disconnect refresh page will increase server and client resource consumption)

Server push (servers pushing technology)
Push technology is to establish a connection, the server actively to the latest information flow to the client
No need to constantly build disconnected, do not need to refresh the page, in contrast, push technology more efficient and faster

But unfortunately, the ASP has been unable to implement erver push technology

Have seen the Microsoft Web site to provide ASP push technology solutions, using the dead loop to achieve server delay implementation of the servers push technology, this code as long as a client execution, CPU occupancy immediately reached 100%, the most important is the ASP thread limit, open this page, All other ASP pages must be queued for this page to finish executing.

Implementation of ASP server without flush push technology
-----------------------------
Reprint please indicate the source: a crane. net_www.1he.net

First I wrote a ASPpush.DLL in C + +, with the ASP code to achieve 0 load delay effect
Download Asppush.dll:http://www.1he.net/asppush/asppush.exe

Using ASP directive Enablesessionstate=false to break through ASP's thread limit
(This is the most important place, in fact, the ASP itself is multithreaded the reason why you can only get single-threaded in the ASP is the ASP for each session to produce a thread, if the ASP page in front of the enablesessionstate=false instructions, You can get a separate thread and a TCP connection to continue to push new information to the client.

Using ASP's Response.IsClientConnected attribute to judge the connection to recover resources in time

Using the above method, I made a chat room,
After testing, 100 people chat online, the system's full CPU consumption of not more than 5% (Windows 2003),
No more than a chat room with client refresh, whether in memory footprint or CPU usage

In fact, the use of client-side refresh is still a persistent resource footprint for the server, and must be frequent connection disconnect, for the chat room, the client refresh of the chat room resource occupancy is not any advantage, and the speed is very slow


Preparatory work
-----------------------------
Reprint please indicate the source: a crane. net_www.1he.net

Download Asppush.dll:http://www.1he.net/asppush/asppush.exe

After decompression, run first: Com.reg (this file adds a submenu of the registered Com component to the right-click menu)

Copy the ASPpush.dll to the system directory
Windows2000 $:/winnt/system32
Windows2003 $:/windows/system32

Right-click System32/asppush.dll
Click "Register DLL" in the right mouse menu
(You can, of course, register at the command line: Regsvr32 $:/windows/system32/asppush.dll)

Note: $: Replace with system disk


Sample code
-----------------------------
Reprint please indicate the source: a crane. net_www.1he.net

The following is a sample code that implements server push using ASPpush.DLL:

<%@ language= "VBScript" codepage = "936" Enablesessionstate=false%>
<%
Response.Buffer = True

Set Asppush = Server.CreateObject ("Asppush.page")
Do While response.isclientconnected
'================================
' Modify or customize the ASP code to be executed here
Response.Write "I faint ...<br>"
'================================
Response.Flush
The number following the Asppush.wait 100 is in milliseconds (1000 milliseconds = 1 seconds), specifying the speed of the push
Loop
Set asppush=nothing
%>


This article mainly introduces the principle of push technology in ASP, as for the specific implementation may also need your own play

----------
Note:

Batch file Seeder Latest version: Web site program making necessary tools
http://jh.1he.net/yes/down/list.asp?id=106

A few days ago wrote a small software: Simulation Wizard, although very simple, but very practical, but also very fun
Also a prerequisite desktop tool, recommended download:
Http://jh.1he.net/twtbbs/showtopic.asp?id=16931&passre=&forumid=41



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.