Know your Byte Code

This is an amazing write-up:

HikariCP offers a high-performance JDBC Pool

Manage Node Connection Provider

Curator Framework simplifies ZooKeeper :  offers robust management for distributed systems.

Ref :

Automatic connection management:

  • There are potential error cases that require ZooKeeper clients to recreate a connection and/or retry operations. Curator automatically and transparently (mostly) handles these cases.
  • Watches for NodeDataChanged events and calls updateServerList() as needed.
  • Watches are automatically removed by Curator recipes

Cleaner API:

  • simplifies the raw ZooKeeper methods, events, etc.
  • provides a modern, fluent interface

Recipe implementations (see Recipes):

  • Leader election
  • Shared lock
  • Path cache and watcher
  • Distributed Queue
  • Distributed Priority Queue

More specifically ,

The Curator Framework constantly monitors the connection to the ZooKeeper ensemble. Further every operation is wrapped in a retry mechanism. Thus, the following guarantees can be made:

  • Every Curator operation properly waits until the ZooKeeper connection is established
  • Every Curator Framework operation (create, getData, etc.) is guaranteed to manage connection loss and/or session expiration per the currently set retry policy
  • If the connection is temporarily lost, Curator will attempt to retry the operation until it succeeds per the currently set retry policy
  • All Curator recipes attempt to deal with connection issues in an appropriate way

Always Manage Executor Threads:

  • — converts the given ThreadPoolExecutor into an ExecutorService that exits when the application is complete.
  • Example :
    • maintain a safe map of listeners –  private final Map<T, ListenerEntry<T>> listeners = Maps.newConcurrentMap();
    • each listenerEntry caontains – addListener(listener, MoreExecutors.sameThreadExecutor());

Provide a Facade over Queue:

Since a queue can handle only certain number of items, say ZooKeeper’s transport layer ,  a facade like QueueSharder can be used to monitor the queues and if any one of them goes over a threshold, a new queue is added.

Always broadcast Notifications :

ConnectionStateListenable().addListener(new ConnectionStateListener() {
public void stateChanged(CuratorFramework client, ConnectionState newState) {
                System.out.println(“** STATE CHANGED TO : ” + newState);

Provide pluggable Error Policies

Track the Metrics

ex. Servo provides a simple interface for exposing and publishing application metrics , MetricsConsumerBolt

Enqueue streaming data and process streams

example: create an Storm Event Processing topology :

  • generate Spout configs (scheme, offsetTime, buffSize, fetchMaxWait, socketTimeout….)
  • spawn QueueSpout (say Kafka)
  • tighten the input and output Bolts
    • leverage the fact that this Bolt can accept a Tuple and emit collection to OutputCollector.
  • config Storm Nimbus
  • submit Topology to a cluster

Embrace smart messaging proxy

Example :  Fabric8MQ

  1. Protocol Conversion — by moving MQTT,STOMP,AMQP protocol conversion outside of the ActiveMQ broker reduces the amount of work the broker needs to do: As ActiveMQ isn’t well designed for modern, asynchronous tasks, the less work the broker does, the better.
  2. Camel Routing is built right into the router — so we can easily convert on the fly between, say Topics (Publish/Subscribe) and Queues (point-2-point).
  3. API Management — utlizing API Man, so you can apply security and rate limiting policies to destinations
  4. Multiplexer — reducing the amount of physical connections an ActiveMQ broker has, increases the throughput of the overall system.
  5. Destination Sharding — this is where a lot of the magic pixie dust is used, to shard connections across many different backend ActiveMQ brokers. Its also where messages and clients are moved between brokers, as brokers are spun up and down, depending on load
  6. Broker Control — this monitors the brokers under Fabric8MQ’s control and monitors load — and it decides if more ActiveMQ brokers are needed, or less — depending on load. An embedded rules engine is used to make the decisions.

Always adopt a flexible Test framework:

Adopt a highly efficient and expressive Data Structure:

example :

 excerpts from ..
 6 public Iterable<Integer> findAllIdsForLastNameSortedByIdUsingJava7(
 7         Iterable<Person> people, String lastName) {
 9     return FluentIterable
10             .from(people)
11             .filter(new Predicate<Person>() {
12                 public boolean apply(Person input) {
13                     return input.getLastName().equals(lastName);
14                 }
15             })
16             .transform(new Function<Person, Integer>() {
17                 public Integer apply(Person input) {
18                     return input.getId();
19                 }
20             })
21             .toSortedList(Ordering.natural());
22 }

References :

  • MutableList<Address> addresses = people.collect(Person.TO_ADDRESS);
public class Person {
public static final Function<Person, Address> TO_ADDRESS = person -> person.getAddress();
  • MutableList<Person> adults = -> each.getAge() >= 18);

many more cool high-performance library ..  Agrona  , FastUtil

Simplify Regex Handling:

Finally a Great Library :

VerbalExpression testRegex = VerbalExpression.regex() .startOfLine().then(http).maybe(s) .then(://) .maybe(www.).anythingBut( ) .endOfLine() .build();


Always use an efficient Serializer:

eg: Kryo is a fast and efficient object graph serialization framework …

Track latency of Operations:

Servers should use Non-Blocking-IO

e.g.  Netty , Grizzly

For fast reactive task execution use CompleteableFuture


Result Processors via CompletebaleFuture chain – ,

Combining multiple completable futures ~


Excellent InfoQ Presentation ~

Leverage ‘string joining’, ‘static interface methods’.’sorting’,’grouping’,’combining predicates’,’parallel streams’ ~ ,

Refactoring to Functional Style with Java 8 , Reactive programming patterns in Java

A Crash Course in Modern Hardware by Cliff Click

Finally the Java libraries you can never miss !

Production~ Guice, Guava,OkHttp, Retrofit, JDeferred, RxJava,Mbassador,Lombok (pojo Generator) ,Slf4j

Test~ Jukito, Awaitility, Spock,WireMock,Mockito,JunitParams

Guava UtilsJava 8 Collections , Java Object Size

Enterprise Java Apps ~ using Cassandra and Spring Connector –

Comprehensive testing using Spring MockMvc ~

Spring 5 now support reactor-streams ~ a key feature to build low-latency application (handling  back pressure and supporting declarative-style composition API)


Nice Explanation of Bloom Filter ~

Performance Tuning ~