Netty

From air
Jump to navigation Jump to search

http://netty.io/

http://mvnrepository.com/artifact/io.netty

Netty is an asynchronous event-driven network java application framework for rapid development of maintainable high performance protocol servers & clients.


Netty is a NIO client server framework which enables quick and easy development of network applications such as protocol servers and clients. It greatly simplifies and streamlines network programming such as TCP and UDP socket server.

'Quick and easy' doesn't mean that a resulting application will suffer from a maintainability or a performance issue. Netty has been designed carefully with the experiences earned from the implementation of a lot of protocols such as FTP, SMTP, HTTP, and various binary and text-based legacy protocols. As a result, Netty has succeeded to find a way to achieve ease of development, performance, stability, and flexibility without a compromise.

Getting Started

Récuperer les exemples du livre Netty in Action

git clone https://github.com/normanmaurer/netty-in-action.git
cd netty-in-action/
git checkout 2.0-SNAPSHOT
mvn clean install

Depuis terminal 1, lancer l'EchoServer

cd chapter2
cd Server/
mvn exec:java


Depuis terminal 2, lancer l'EchoClient

cd chapter2
cd Client/
mvn exec:java


Exemples du dépôt Netty

Prérequis : Git, Java et Maven

Sur 3 machines client-1, proxy-1 et server-1

git clone https://github.com/netty/netty.git
cd netty
mvn clean install -DskipTests

./run-example.sh

# Configurer les variables
# en test local
FRONTEND=127.0.0.1
NETWORKSERVER=127.0.0.1
# en test sur un cluster multi-machine ou avec Docker
PROXY=proxy-1
SERVER=server-1

Expérimentation 1: echoclient x3 --> dumpproxy --> echoserver

Sur server-1

SSL_OPTIONS=-Dssl=false
./run-example.sh -DlogLevel=debug $SSL_OPTIONS -Dport=1202 echo-server

Sur proxy-1

./run-example.sh -DlogLevel=debug -DlocalPort=1201 -DremotePort=1202 -DremoteHost=$SERVER proxy-server

Sur client-1 (3 terminaux)

Sur un terminal 1 de client-1

SSL_OPTIONS=-Dssl=false
./run-example.sh -DlogLevel=debug $SSL_OPTIONS -Dhost=$PROXY -Dport=1201 echo-client

Sur un terminal 2 de client-1

SSL_OPTIONS=-Dssl=false
./run-example.sh -DlogLevel=debug $SSL_OPTIONS -Dhost=$PROXY -Dport=1201 echo-client

Sur un terminal 3 de client-1

SSL_OPTIONS=-Dssl=false
./run-example.sh -DlogLevel=debug $SSL_OPTIONS  -Dhost=$PROXY -Dport=1201 echo-client

Expérimentation 2: echoclient x3 --SSL--> dumpproxy --SSL--> echoserver

Commandes identiques avec la variable suivante:

SSL_OPTIONS=-Dssl=true

Remarque: le serveur génère un certificat X509 auto-signé.


Expérimentation 3: Discard example

Sur server-1
# Remarque: SSL pass-thru
SSL_OPTIONS=-Dssl=false
./run-example.sh -DlogLevel=debug $SSL_OPTIONS  -Dport=1201 discard-server

Sur un terminal 1 de client-1
SSL_OPTIONS=-Dssl=false
./run-example.sh -DlogLevel=debug $SSL_OPTIONS -Dhost=$SERVER -Dport=1201 -Dsize=1024 discard-client

Expérimentation 4 : Microbenchmarks extensibles

cd microbenchmark
mvn -DskipTests=false -DwarmupIterations=2 -DmeasureIterations=3 -Dforks=1 test

Projets connexes

Nifty

Nifty is an implementation of Thrift clients and servers on Netty.

Finagle

Projet open-source de Twitter utilisant Netty et ajoutant des fonctions de load-balancing, de failover, de trace (avec Zipkin) ...

Autres

Livre