Apache Proxy Balancer

Enable proxy models

sudo a2enmod proxy_html
sudo a2enmod proxy_http
sudo a2enmod proxy_wstunnel
sudo a2enmod proxy_ajp
sudo a2enmod lbmethod_byrequests
sudo a2enmod lbmethod_bytraffic
sudo a2enmod lbmethod_bybusyness
sudo a2enmod lbmethod_heartbeat
Read More

Create a MongoDB Replica Set

Create 3 mongodb servers. Make sure update hosts files on all nodes or on DNS server mongodb01 mongodb02 mongodb03
Read More

Backup LXD Container as Tarball


lxc snapshot <container name> backup
lxc publish <container name>/backup --alias <container name>-backup
lxc image export <container name>-backup lxd_<container name>_tarball
lxc image delete <container name>-backup
lxc delete <container name>/backup
Read More

Volatile Variable in Java

What is volatitle variable?

volatile variable in Java is a special variable which is used to signal threads, a compiler that this particular variables value are going to updated by multiple threads.

  1. Variable’s value is always read from main memory instead of cached value.
  2. Volatile variable guarantees “happens-before” relationship, which means not only another thread has visibility of latest value of volatile variable but also all the variable is seen by the thread which has updated value of volatile variable before these thread sees it.
Read More

Difference Between map and flatMap in Java 8

Definition in Java 8 Stream and Optional


  • map: If a value is present, apply the provided mapping function to it, and if the result is non-null, return an Optional describing the result. Otherwise return an empty Optional.
  • flatMap: If a value is present, apply the provided Optional-bearing mapping function to it, return that result, otherwise return an empty Optional. This Method is similar to map(Function), but the provided mapper is one whose result is already an Optional, and if invoked, flatMap does not wrap it with an additional Optional.
Read More