. NET high concurrency application implementation, asynchronous single-threaded non-blocking solutions

Source: Internet
Author: User
Tags access database

Ggkserver framework, based on C #. NET (4.0) development, the main call library API.DLL is. NET to develop Web applications in a new way to achieve universal application.

Ggkserver uses forced gzip compression for static capacity, forcing caching (intelligently releasing the cache).

The main implementation of Ggkserver is asynchronous single-threaded non-clogging socket service using the SocketAsyncEventArgs asynchronous object pool, similar to IOCP.

Ggkserver initiates a queue pool of processing objects based on the maximum queue set by the site, receives a request for a pop object for processing, and then push back to the pool when it is finished.

Ggkserver Initializes a buffer for each object in the pool, eliminating the burden on the CPU by avoiding requests for memory space to the operating system each time it is received.

Objects in the Ggkserver pool are never freed and objects are reused.

Ggkserver can be specific to what each thread is working on, each site has a main thread, a socket service thread, a cache, and session-managed threads.

Framework installation package share address: http://pan.baidu.com/s/1mg1KuFm

installation directory after installation

New Project

Write the first Hello interface and then build the project

Configuration Item-"Find the gsys.accdb file in the installation directory, this is an Access database file (so you must install Access 2007 or later database)-" Edit the Site table, the field meaning is as follows:

Field name Role Note
Name Site name
AppPath Site Main program Path *.dll,*.exe (required)
Contentpath Common content folder path (static file) {such as: c:\web\}[note end ' \ '] Content forced cache, directory changes automatically clear cache (required)
Backlog Number of application pool queues, concurrent volume The application pool Initializes a pool in memory based on this number, configured according to the actual site requirements (10w=1g memory) (required)
Prot Site Port Access port (required)
Receivebuffsize Maximum number of accepted data, in bytes (default 10240) This setting affects the size of the data that the socket can receive, which is actually the size of the socket buffer, which is initialized to the application pool when the site is started and pegged to the actual memory consumption.
ReceiveTimeout Accept data time-out, per millisecond Refer to MSDN Sockets
Sendtimeout Send data time-out, per millisecond Refer to MSDN Sockets
Remark Note
Adminid Administrator ID Associated with the user table, the field is invalid because the version does not support remote administration
Scprot Cluster port This field is invalid because the Cluster service is not supported in this version
CacheTime Cache time, per millisecond Cache cleanup Interval Time
Sessiontimeout Session state save time, per millisecond Session state save time, when the user in the time to operate the state continues to delay valid

the port I set is: 8001

Apppath= the newly created ConsoleApplication1 project startup file,

mine is C:\Documents and settings\administrator\ desktop \consoleapplication1\consoleapplication1\bin\debug\ ConsoleApplication.exe

I set the public content path to D:\

Contentpath=d:\

start the service

Start the installed service program

Come on, visit our first interface, Hello world~

Access address =http://native IP: Port/Project Namespace/class name/function name

So my access address is: Http://192.168.2.112:8001/ConsoleApplication1/Class1/Hello

Public content access address =http://native IP: Port/[file path]

Successful output hello .... Accessing a static file does not demonstrate.

API Library Overview

Object Name Description Note
Request Request object, like the request property of ASP.
Response Response objects, like the response property of ASP.

Request Object Overview

Property name Description Note
Dgetsession Gets the delegate object for session data
Dsetsession Delegate object to set session data
Cookies Cookie collection (hash table), get method: String str1=request.cookie["cookie name". ToString ()
Ipinfo User IP Information
SessionID Session Status Indicator
Method Mode get, post for customer request
Uri Request full path
Httprequestcontext Request messages from the client
Parames Parameter collection (hash table), get method: String str1=request.parames["parameter name"]. ToString ()
Heads Request packet Header (hash table), get method: String str1=request.heads["key"]. ToString ()
Session Get Session data function, call method: Object Obj=request.session ("Session name"), no data returned null We recommend that you use stateless methods to develop Web apps without session.
Setsession Set session data function, call method: Request.setsession ("Session name", value) We recommend that you use stateless methods to develop Web apps without session.

Response Object Overview

  output character content, calling method: Response.Write ("Content", True/false)   True or false indicates whether the content is gzip compressed /tbody>
Property name Description remarks
socketobject User-connected Socket object, can implement custom send data  
statusinfo response status information, corresponding to the response status code, default OK &nbs P;
Status response status code, default:  
Heads response header
responsecontext response content  
Write  
WriteFile Output file, call method Response.WriteFile (true/false,true/false, "File path"), the first parameter indicates whether the connection is closed after the output file, and the second parameter indicates whether to add a response header, Output pure binary stream   without adding;
writejson output JSON data, calling Method: Response.Write ("Content", True/false) & nbsp True or false indicates whether the content is gzip compressed  
End    

About concurrency you can write your own program tests.

Welcome everyone to comment: [email protected]

. NET high concurrency application implementation, asynchronous single-threaded non-blocking solutions

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.