QBit development microservice

Source: Internet
Author: User

QBit development microservice
I. QBit database Introduction

QBit is an open-source responsive development library used to build microservices and supports JSON, HTTP, WebSocket, and REST. QBit uses responsive programming to establish elastic REST, cloud-based WebSocket, and Web services. QBit is an SOA evolution for mobile and cloud computing. QBit is a small, lightweight microservice development library that provides support for service discovery, service health, responsive state services, type events, and reactive programming commonly used in Java.
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'}

Currently, the latest version of QBit microservice library is 0.9.0.M2.

Iii. Use QBit to write sample code
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();    }}
4. Run the code
# gradle run
5. Use curl for testing
$ curl http://localhost:8080/root/hello/hello"hello 1440742489358"
6. Test with wrk

Wrk is an open-source HTTP Benchmark Testing Tool. When running on a single multi-core CPU, wrk can produce significant load. It combines multi-threaded design and scalable event notification systems (such as epoll and kqueue ).
Wrk also provides an optional LuaJIT script for executing 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

This article permanently updates the link address:

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.