3. Asynchrony
●
Most web frameworks are blocking and synchronous.
– 1000 concurrent requests require 1000 threads.
– In modern systems, a service sends requests to another backend.
– Threads are busy doing nothing but just waiting for the backend.
– Request queue is not consumed fast enough.
– Result:
●
Fragile system that falls apart even on a tiny backend failure
●
Inefficient system that takes more memory and CPU than what it actually does
4. Reactive Streams
●
Should we really buffer everything until a response is sent?
– Retrieving 100,000 rows from a table
●
Why should a client send many requests to reduce the server memory
pressure?
– Retrieving 1,000 rows 100 times
●
What if we want to stream infinitely?
– Stock quotes
●
Our protocol is not a problem here.
– Our ‘blocking’ programming model is blocking ‘us’.
5. Better RPC support
●
RPC has been hardly a 1st-class citizen in web
frameworks.
– Distinction from RPC-level and HTTP-level failure
– Access logs with RPC-level details
– Debugging console
●
What if …
– We build a microservice framework with RPC at its core?
6. More reasons back in 2015
●
Leverage Java 8 syntax
– Lambda expressions
– Default interface methods
– Static interface methods
●
Provide ‘working’ HTTP/2 implementation
– ‘H2C’ support (HTTP/2 over ‘C’leartext)
– OpenSSL-based faster TLS connection
7. Better UX for devs
●
This is the last yet most important part.
●
Nobody wants a framework that’s hard to use.
●
Can we design …
– a user-friendly asynchronous programming API
– … with modest learning curve?
8. Our answer – Armeria
●
HTTP/2
– Both ciphertext and cleartext, a.k.a. h2 and h2c
●
Reactive
– Implements Reactive Streams API
●
Ability to mix different types of services in a single server
– gRPC, Thrift, REST services
– Legacy webapps via embedded Tomcat or Jetty
●
High-performance
– Netty with /dev/epoll transport and BoringSSL SSLEngine
●
Easy to learn and fun to use (hopefully)
16. There are more!
●
Query parameters
●
Request and response converters
●
Exception handlers
●
Content type negotiation
●
Regular-expression path mapping
●
Aims to be on-par or better than <your favorite web framework>
18. gRPC & Thrift basics
a. Write an IDL file – .proto or .thrift
b. A compiler compiles it into .java files.
c. Implement interfaces generated at ‘b’.
27. Armeria documentation service
●
Enabled by adding DocService to ServerBuilder
●
Browse and invoke RPC services in an Armeria server
●
Supports both gRPC and Thrift
●
We have a plan to add:
– Support for plain HTTP, like Swagger
– Metric monitoring console
– Runtime configuration editor, e.g. logger level
34. Armeria client API
●
Similar experience to the server-side API
– e.g. Common type, Decorators, RPC-friendliness
●
Client-specific stuff
– Circuit breakers
– Automatic retries
– Client-side load balancing
– Retrofit integration