Skip to content

kymo/SUNET

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

91 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SUNET


SUNET is a raw light strategy server framework written in C++.

Non-blocking IO Model

you can define epoll or select model as you want. the sockets are non-blocking and the epoll works under ET mode. Main thread maintains the epoll loop, and if there is a new connection from client, the main thread receives the data and hand it to the work thread queue.

Multi-thread task queue

task queue are visited by thread pool through a read-write thread lock. the work thread firstly parses the received data into Request format(url, method, params etc.), and then the strategy-mgr calls the method binded to the uri, and write the return data into Json Object.

Algorithm modules Configurable

algorithms are exists as plugins. you can add you own add you own algorithm modules by inherting the abstact class IStrategy and implement the virtual function defined in it. and then just defined the uri that your algorithm modules work on.

Usage

suppose your strategy.conf and sub.conf are defined as follows:

strategy.conf

[/]
TextStrategy:255
RewriteStrategy:255
[/search]
TextStrategy:255
RewriteStrategy:255

sub.conf

crf_model:/*/SUNET/alias/wordseg/model
port:9000
thread_cnt:10
log_level:15
log_path:./log/

You can start the server just by run [./sub port]. then you can visit the defined uri in you strategy.conf. for exammple.

curl -s http://ip:port/?q=南京市长江大桥

the response data should be:

{
"rewrite" : "yes",
  "seg" : "南京市_长江_大桥_",
"text" : "yes"
}

Make

cd io sh make.sh

Test

5871381 fetches, 10 max parallel, 4.87325e+08 bytes, in 1000 seconds
83 mean bytes/connection
5871.38 fetches/sec, 487325 bytes/sec
msecs/connect: 0.0415055 mean, 3.225 max, 0.014 min
msecs/first-response: 1.65957 mean, 220.13 max, 0.713 min
HTTP response codes:
code 200 -- 5871381

About

a light strategy server framework.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published