|
One, QBit library introduction
QBit is an open source responsive development library for building micro-services support JSON, HTTP, WebSocket and REST. QBit using reactive programming create a flexible REST, cloud-based WebSocket, Web services. QBit is SOA evolution for mobile and cloud computing. QBit is a small, lightweight micro-services development bank, provides discovery services, health services, responsive service status, type of event, as well as the usual reaction Java programming support.
QBit very small and fast.
Two, Gradle build file
group 'qbit-ex'
version '1.0-SNAPSHOT'
apply plugin: 'java'
apply plugin: 'application'
mainClassName = "com.mammatustech.HelloWorldService"
compileJava {
sourceCompatibility = 1.8
}
repositories {
mavenCentral ()
mavenLocal ()
}
dependencies {
testCompile group: 'junit', name: 'junit', version: '4.11'
compile group: 'io.advantageous.qbit', name: 'qbit-admin',
version: '0.9.0-M1'
compile group: 'io.advantageous.qbit', name: 'qbit-vertx',
version: '0.9.0-M1'
}
Currently QBit micro-service library latest version to version 0.9.0.M2.
Third, write the sample code with QBit
package com.mammatustech;
import io.advantageous.qbit.admin.ManagedServiceBuilder;
import io.advantageous.qbit.annotation.RequestMapping;
@RequestMapping ( "/ Hello")
public class HelloWorldService {
@RequestMapping ( "/ Hello")
public String hello () {
return "hello" + System.currentTimeMillis ();
}
public static void main (final String ... args) {
final ManagedServiceBuilder managedServiceBuilder =
ManagedServiceBuilder.managedServiceBuilder ()
.setRootURI ( "/ root");
/ * Start the service. * /
managedServiceBuilder.addEndpointService (new HelloWorldService ())
.getEndpointServerBuilder ()
.build () startServer ().;
}
}
Fourth, run the code
# Gradle run
Fifth, with the curl test
$ Curl http: // localhost: 8080 / root / hello / hello
"Hello 1440742489358"
Six test with wrk
wrk is an open source HTTP benchmarking tool. When wrk run on a single multi-core CPU, it is possible to generate a significant load, which combines a multi-threaded design and extensible event notification system (such as epoll and kqueue).
wrk also offers an optional LuaJIT script that can be used to generate the implementation of the HTTP request, processes the response, as well as custom reports.
Home: https://github.com/wg/wrk
$ Wrk -d 5s -t 2 -c 1000 http: // localhost: 8080 / root / hello / hello
Running 5s test @ http: // localhost: 8080 / root / hello / hello
2 threads and 1000 connections
Thread Stats Avg Stdev Max +/- Stdev
Latency 17.65ms 22.96ms 427.36ms 97.57%
Req / Sec 33.33k 7.75k 43.10k 75.00%
319154 requests in 5.06s, 28.00MB read
Requests / sec: 63083.97
Transfer / sec: 5.53MB |
|
|
|