Measure the Dubbo function of Tengine open source

roshilikang 2021-09-15 04:25:13
measure dubbo function tengine open


This article has been included https://github.com/lkxiaolou/lkxiaolou welcome star.

background

  • Tengine Alibaba is based on Nginx Developed and open source Web The server , It inherited Nginx All the functions and features , And on the basis of it, we have done a lot of expansion and enhancement , Such as dynamic module loading , Four layer load balancing ,reuseport Ability to support , It's all gradually being ignored Nginx Official absorption and citation .Tengine It's very popular after open source , Become Nginx One of the best alternatives , Official website (http://tengine.taobao.org/).

  • Dubbo It's a high-performance product of Alibaba open source 、 Lightweight open source Java RPC frame , It provides three core competencies : Interface oriented remote method call , Intelligent fault tolerance and load balancing , And automatic service registration and discovery .

2019 year 9 month ,Tengine 2.3.2 Version released dubbo_pass modular , Support HTTP The agreement reached Dubbo Protocol conversion .Release The page is as follows :

https://github.com/alibaba/tengine/releases/tag/2.3.2

significance

《Gateway The technological revolution - Tengine Open source Dubbo function 》 Yes Tengine Support Dubbo The meaning of the agreement is quite clear , The conclusion is as follows :

  • Structure optimization : Reduce one layer of forwarding , Reduce system complexity ;
  • Performance advantages : The data are given in this paper ,“Tengine Direct support for Dubbo Architecture in CPU Consumption and RT In different scenes , Yes 28%-73% Different performance advantages ”

Actually measured

Tengine Environment building

Here I use centos The basic image of a set of Tengine Environmental Science , Give me a brief description of the steps :

  • Into the container , Create a working directory
mkdir -p /home/roshi && cd /home/roshi/
  • Download the source code and unzip it
wget https://github.com/alibaba/tengine/archive/2.3.2.zip
unzip 2.3.2.zip && cd tengine-2.3.2/

wget https://ftp.pcre.org/pub/pcre/pcre-8.43.tar.gz
tar xvf pcre-8.43.tar.gz

wget https://www.openssl.org/source/openssl-1.0.2s.tar.gz
tar xvf openssl-1.0.2s.tar.gz

wget http://www.zlib.net/zlib-1.2.11.tar.gz
tar xvf zlib-1.2.11.tar.gz
  • Installation dependent
yum install gcc
yum install gcc-c++
yum -y install gcc automake autoconf libtool make
  • compile
./configure --add-module=./modules/mod_dubbo --add-module=./modules/ngx_multi_upstream_module --add-module=./modules/mod_config --with-pcre=./pcre-8.43/ --with-openssl=./openssl-1.0.2s/ --with-zlib=./zlib-1.2.11
make && make install
  • start-up
/usr/local/nginx/sbin/nginx

Dubbo Example

I want to mention that before 《dubbo First experience of application level service discovery 》 Quick build mentioned in Dubbo Ways to debug the environment :

  • git clone https://github.com/apache/dubbo.git
  • Use /dubbo-demo Examples in the directory , This article USES the /dubbo-demo/dubbo-demo-api-provider The following example

because Tengine Limited , The outgoing and incoming parameters of an interface must be Map<String, Object>, So you need to modify the example :

  • DemoService
public interface DemoService {

    String sayHello(String name);

    default Map<String, Object> testTengine(Map<String, Object> args) {
        return null;
    }

    default CompletableFuture<String> sayHelloAsync(String name) {
        return CompletableFuture.completedFuture(sayHello(name));
    }
}
  • DemoServiceImpl.java
public class DemoServiceImpl implements DemoService {
    private static final Logger logger = LoggerFactory.getLogger(DemoServiceImpl.class);

    @Override
    public String sayHello(String name) {
        logger.info("Hello " + name + ", request from consumer: " + RpcContext.getContext().getRemoteAddress());
        return "Hello " + name + ", response from provider: " + RpcContext.getContext().getLocalAddress();
    }

    @Override
    public Map<String, Object> testTengine(Map<String, Object> args) {
        Map<String, Object> res = new HashMap<>();
        res.put("body""hello tengine dubbo\n");
        res.put("status""200");
        System.out.println("testTengine");
        return res;
    }

    @Override
    public CompletableFuture<String> sayHelloAsync(String name) {
        return null;
    }

}

In order to better test multiple provider The situation of , You can use the same code , Multiple services on different ports .

modify Tengine To configure

  • vi /usr/local/nginx/conf/nginx.conf
worker_processes  1;

events {
    worker_connections  1024;
}

http {
    include       mime.types;
    default_type  application/octet-stream;

    sendfile        on;

    server {
        listen       8080;
        server_name  localhost;

        #pass the Dubbo to Dubbo Provider server listening on 127.0.0.1:20880
        location / {
            dubbo_pass_all_headers on;
            # dubbo_pass_set args $args;
            dubbo_pass_set args hello;
            dubbo_pass_set uri $uri;
            dubbo_pass_set method $request_method;

            dubbo_pass org.apache.dubbo.demo.DemoService 0.0.0 testTengine dubbo_backend;
        }
    }


    #pass the Dubbo to Dubbo Provider server listening on 127.0.0.1:20880
    upstream dubbo_backend {
        multi 1;
        server host.docker.internal:20880;
        server host.docker.internal:20881;
    }
}
  • After modifying the configuration reload To configure , Make it effective
/usr/local/nginx/sbin/nginx -s reload

test

Use the following command to test

curl -X POST http://127.0.0.1:8080/dubbo -i -d "hello=roshi"

Let's take a look at the transmission of the reference

summary

After testing , Summarize the following :

  • The output and input parameters of the interface are fixed to Map<String, Object>, Otherwise, an error will be reported
  • Use body The ginseng , To Dubbo On the side is byte[], You also need to parse
  • Can control the return of body and http Status code , Which returned body It can be String, It can also be byte[] type , Status code is String type
  • Have Tengine Native load balancing algorithm
  • It has the function of fault removal ,Tegine And Dubbo Provider Long connections will be established , If it is disconnected, it will be removed
  • Unrealized version、group Grouping function , In document version There is no effect in the actual measurement

Last

just as 《Gateway The technological revolution - Tengine Open source Dubbo function 》 What is said in the article ,Tengine Just finished as Dubbo Consumer Protocol support for , Like service discovery 、 Custom interface 、 Service group 、 Other functions such as fault tolerance and degradation have not been implemented yet , For the time being, it's still a long way from production .

Finally, I want to make complaints about it. Tengine Documents on the official website

Reference resources

  • Official documents http://tengine.taobao.org/document_cn/ngx_http_dubbo_module_cn.html
  • The official example https://github.com/apache/dubbo-samples/tree/master/dubbo-samples-tengine

WeChat official account " Master bug catcher ", Back end technology sharing , Architecture design 、 performance optimization 、 Source code reading 、 Troubleshoot problems 、 Step on the pit practice .

版权声明
本文为[roshilikang]所创,转载请带上原文链接,感谢
https://javamana.com/2021/09/20210909112309737h.html

  1. Java 16 is coming online. You can't even use the features of Java 8, can you?
  2. Java (3) basic data types and their type conversion
  3. 一位Java大牛的BAT面试心得与经验总结,2021年Java春招面试经历,
  4. 一举拿下腾讯美团滴滴offer,快来瞧瞧这份Spring面试小抄!
  5. 一个Java应届生从上海离职,万字长文总结Java多进程,
  6. Seven design principles of java object-oriented design pattern
  7. 一個Java應届生從上海離職,萬字長文總結Java多進程,
  8. Un nouvel étudiant Java a quitté Shanghai et a résumé plusieurs processus Java.
  9. Prenez d'un coup l'offre de Tencent meituan et jetez un coup d'oeil à cette copie de l'entrevue de printemps!
  10. L'expérience et l'expérience d'un Maverick Java en matière d'entrevue sur les MTD, l'expérience de l'entrevue d'embauche du printemps Java en 2021,
  11. Interface graphique X: mise à jour des tables de rendu et optimisation du Code (compilation intégrée 10)
  12. Widget de vérification de fichiers personnalisés Linux
  13. Java thread pool - work queue
  14. [Part 7] - Summary of B2B2C e-commerce technology of spring cloud live mall managed by git branch
  15. Reflection type of Java Foundation
  16. Want to get started with data structures, but always fall under the pomegranate skirt of the linked list?
  17. Interviewer: do redis transactions satisfy atomicity?
  18. 一篇文章教你搞定计算机网络面试,350道Java面试真题分享,
  19. 一条正确的Java职业生涯规划,揭秘今年Java春招面试必问问题有哪些?
  20. 一名毕业三年的女程序媛面试头条经验,关于Redis主从节点数据过期一致性的思考,
  21. Huawei cloud guassdb (for redis) released a new version: Lua script and SSL connection encryption
  22. Java thread pool - work queue
  23. 一名畢業三年的女程序媛面試頭條經驗,關於Redis主從節點數據過期一致性的思考,
  24. Trois ans d'expérience d'entrevue avec une femme de programmation diplômée, une réflexion sur la cohérence de l'expiration des données de redis Master slave Node,
  25. Un plan de carrière Java correct, découvrez les questions que vous devez poser lors de l'entrevue d'embauche du printemps Java de cette année.
  26. 万字详解微服务的哨兵机制,架构师带你玩转Redis高性能缓存设计实战,
  27. Un article vous a appris à gérer les entrevues sur le Web, à partager 350 vraies questions d'entrevue Java,
  28. Jquery Tools Methodology collation, Sharing a little interview Experience
  29. Tutoriel de développement Java, compétences de base nécessaires pour interviewer un programmeur Java dans une grande usine,
  30. "Anti Mafia storm" has just finished, another criminal investigation play has come, and the supporting actor is more popular than the protagonist
  31. 萬字詳解微服務的哨兵機制,架構師帶你玩轉Redis高性能緩存設計實戰,
  32. L'architecte vous guidera dans la conception de cache haute performance de redis.
  33. Linux驱动开发: 杂项字符设备
  34. Jquery plug - in urianchor, app front end Development
  35. Linux驅動開發: 雜項字符設備
  36. Développement de pilotes Linux: périphériques de caractères divers
  37. Utilisez @ async dans Spring boot pour effectuer des appels asynchrones et accélérer l'exécution des tâches!
  38. $in jquery, Visualized Web Development Tool
  39. Le développement Java doit être fait. Les entrevues https demandent souvent une analyse complète.
  40. 不明白JVM虚拟机还怎么面试,一起刷完了这份1307页的Java面试宝典吧,
  41. 不断提升自己创造溢价的能力,字节跳动 阿里 华为 腾讯等大厂Java面试题,
  42. Jdk's Past Life: The Classic Features of Thin Number - java5 - - - 15 -, webfront Development
  43. Résumé des questions d'entrevue pour les ingénieurs en développement Java, analyse des questions d'entrevue à haute fréquence Dubbo,
  44. Améliorer continuellement leur capacité à créer des primes, et les questions d'entrevue Java d'Alibaba Huawei Tencent et d'autres grandes usines sont sautées en octets.
  45. Install docker YJ version of openSUSE 11.3
  46. Je ne comprends pas comment la machine virtuelle JVM peut encore interviewer, et j'ai terminé ce dictionnaire d'entrevue Java de 1307 pages.
  47. 中软国际Java机试,如何写出高效率的SQL?
  48. 中级Java工程师面试,阿里 头条 腾讯等大厂Java笔试题目分享,
  49. 两年Java开发经验,为什么spring能最好地改变Java?
  50. Echarts realizes the rotation of the moon (super simple, you can see it at a glance)
  51. Deux ans d'expérience dans le développement de Java, pourquoi Spring peut - il le mieux changer Java?
  52. Entretien d'ingénieur Java intermédiaire, partage de sujets d'examen écrit Java de grandes usines comme Alibaba headline Tencent,
  53. Zhongsoft International Java Machine test, comment écrire un SQL efficace?
  54. Reflection type of Java Foundation
  55. Comment gérer efficacement les changements dans les ressources k8s?Analyse du mécanisme de mise en œuvre de k8s informer
  56. Installation de jdk1.8
  57. MySQL column - Linux underlying interaction and RAID storage architecture
  58. Interviewer: do redis transactions satisfy atomicity?
  59. 兩年Java開發經驗,為什麼spring能最好地改變Java?
  60. Migration practice from zookeeper to Nacos