Qbit Development Micro-service

Source: Internet
Author: User

Qbit Development of micro-services Chszs, All rights reserved, without consent, may not be reproduced. Blog home: Http://blog.csdn.net/chszs, Qbit Library Introduction

Qbit is an open-source, responsive development library for building microservices that support JSON, HTTP, WebSocket, and rest. Qbit uses responsive programming to build resilient rest, cloud-based WebSocket, and Web services. Qbit is the evolution of SOA for mobile and cloud computing. Qbit is a small, lightweight micro-service development library that provides support for service discovery, service health, responsive state services, type events, and Java-idiomatic reactive programming.
The qbit is very small and extremely fast.

Ii. 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‘}

At present, the latest version of Qbit Micro Service Library is 0.9.0.m2 version.

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();    }}
Four, run the code
# gradle run
Five, with Curl test
$ curl http://localhost:8080/root/hello/hello"hello 1440742489358"
VI. Test with WRK

WRK is an open source HTTP benchmark tool. When WRK is running on a single multicore CPU, it can generate significant load, which combines multithreaded design with extensible event notification systems such as Epoll and Kqueue.
WRK also provides an optional Luajit script that can be used to perform HTTP request generation, response processing, and custom reports.
Home: Https://github.com/wg/wrk

$ wrk -d 5s -t 2 -c 1000 http://localhost:8080/root/hello/helloRunning 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 readRequests/sec:  63083.97Transfer/sec:      5.53MB

Copyright NOTICE: This article for Bo Master Chszs original article, without Bo Master permission not reproduced.

Qbit Development Micro-service

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.