- Always try to figure out if a code that is crashing on very big environment (ie for this case on 100+ asynchronous connection requests) also fails on a much smaller sized environment (ie for this case on 5+ synchronous connection request)
- Try to determine whether you can successfully reproduce the crash on every run of server/code
- If the issue can be successfully reproduced with small number of requests on every run of server that means there is issue with the normal flow of the code
- If the issue can't be reproduced on every run of server and/or on small sized sequential requests then it means that some part of code is throwing an exception which is inhibiting the normal flow of code.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# %% | |
import matplotlib.pyplot as plt | |
import numpy as np | |
import math | |
from scipy.stats import binom | |
# %% | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.io.BufferedReader; | |
import java.io.FileNotFoundException; | |
import java.io.FileReader; | |
import java.io.IOException; | |
import java.net.DatagramPacket; | |
import java.net.DatagramSocket; | |
import java.net.InetAddress; | |
public class Client { | |
public static void main(String[] args) throws IOException { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.net.*; | |
import java.io.*; | |
public class Client { | |
//declearing socket and input output streams | |
private Socket socket = null; | |
ObjectOutputStream dout; | |
ObjectInputStream din; | |
// constructor to put ip address and port |
I found out that 2 threads are optimum in this case. I tried playing around with number of threads using the variables
numThreads = 2
executor.setCorePoolSize(numThreads);
executor.setMaxPoolSize(numThreads);
When I kept the numThreads to 4, (maybe due to i/o bottle neck or due to number of cores in my pc being 2), the response time was worse compared to the synchronous code. keeping it as 2 made the asynchronous implementation fast enough to beat get lower response time compared t o the synchronous case