Skip to content

Instantly share code, notes, and snippets.

View rahul619anand's full-sized avatar

Rahul Anand rahul619anand

View GitHub Profile
package com.test.quartz
import java.util
import org.asynchttpclient.{DefaultAsyncHttpClient, DefaultAsyncHttpClientConfig, Param, RequestBuilder}
import org.asynchttpclient.proxy.ProxyServer
import org.asynchttpclient.ws.{WebSocket, WebSocketTextListener, WebSocketUpgradeHandler}
import org.json4s._
import org.json4s.native.JsonMethods._
import org.json4s.native.Serialization
@rahul619anand
rahul619anand / TCP model
Created May 20, 2017 09:39
Dig deeper into TCP client server connections ...
Each TCP/IPv4 connection in general consists of two endpoints, and each endpoint consists of an IP address and a port number.
Therefore, when a client connects to a server, an established connection can be thought of as the 4-tuple of (server IP, server port, client IP, client port).
When a connection is established from client to server, the client side of the connection will be assigned a source port number (other than reserved range).
Unless a client program explicitly requests a specific port number, the port number assigned is an ephemeral port number.
Ephemeral ports are temporary ports assigned by a machine's IP stack, and are assigned from a designated range of ports for this purpose.
Note : As of Windows Server 2008, it uses a large range (49152-65535) by default.
Every TCP connection must terminate through the TIME_WAIT state before it is really completed.
The purpose of TIME-WAIT is to prevent delayed packets from one connection being accepted by a later connection.
@rahul619anand
rahul619anand / RabbitMQvsKafka.txt
Last active August 22, 2024 18:56
Kafka vs RabbitMQ
RabbitMQ
* Written in Erlang
* Scaling strategies - is mostly vertical
* Supports topics and queues
* if you want to have high persistence guarantees, RabbitMQ ensures replication across the cluster and on disk on message send.
* Reliable message broker as we get acknowledgement (AMQP based)
* Use RabbitMQ if you have messages (20k+/sec) that need to be routed in complex ways to consumers, you want per-message delivery guarantees, you don’t care about ordered delivery, you need HA at the cluster-node level now, and/or you need 24×7 paid support in addition to forums/IRC.
* RabbitMQ is good for “slow” and unreliable consumers
@rahul619anand
rahul619anand / TestThread.scala
Created May 1, 2017 05:25
Simple Scala Executor with Custom Thread Names and Thread StackTrace
import java.util.concurrent.Executors
import com.google.common.util.concurrent.ThreadFactoryBuilder
/**
* Created by ranand on 4/26/2017 AD.
*/
object TestThread {
def main(args: Array[String]): Unit = {
val threadFactory =new ThreadFactoryBuilder()