nginx vs varnish

it has been a long time I am using varnish + apache. and I was reading nginx is really fast. 2 days ago I installed nginx and configure one php page works with it. here are the ab outputs this is varnish mascix@mascix-HP-Pavilion-dv7-Notebook-PC:~/tmp/akka/example-akka-http$ ab -n 100 -c 10 http://sifavi.com/ This is ApacheBench, Version 2.3 <$Revision: 1528965 $> Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/ Licensed to The Apache Software Foundation, http://www.apache.org/ Benchmarking sifavi.com (be patient).....done Server Software: Apache Server Hostname: sifavi.com Server Port: 80 Document Path: / Document Length: 230 bytes Concurrency Level: 10 Time taken for tests: 0.937 seconds Complete requests: 100 Failed requests: 0 Non-2xx responses: 100 Total transferred: 57784 bytes HTML transferred: 23000 bytes Requests per second: 106.73 [#/sec] (mean) Time per request: 93.696 [ms] (mean) Time per request: 9.370 [ms] (mean, across all concurrent requests) Transfer rate: 60.23 [Kbytes/sec] received Connection Times (ms) min mean[+/-sd] median max Connect: 42 45 3.3 44 56 Processing: 43 47 3.6 45 64 Waiting: 43 47 3.5 45 64 Total: 86 92 5.4 90 113 Percentage of the requests served within a certain time (ms) 50% 90 66% 92 75% 96 80% 97 90% 101 95% 102 98% 110 99% 113 100% 113 (longest request) this is nginx mascix@mascix-HP-Pavilion-dv7-Notebook-PC:~/tmp/akka/example-akka-http$ ab -n 100 -c 10 http://sifavi.com:3080/ This is ApacheBench, Version 2.3 <$Revision: 1528965 $> Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/ Licensed to The Apache Software Foundation, http://www.apache.org/ Benchmarking sifavi.com (be patient).....done Server Software: nginx/1.6.2 Server Hostname: sifavi.com Server Port: 3080 Document Path: / Document Length: 17640 bytes Concurrency Level: 10 Time taken for tests: 2.181 seconds Complete requests: 100 Failed requests: 0 Total transferred: 1788400 bytes HTML transferred: 1764000 bytes Requests per second: 45.86 [#/sec] (mean) Time per request: 218.053 [ms] (mean) Time per request: 21.805 [ms] (mean, across all concurrent requests) Transfer rate: 800.94 [Kbytes/sec] received Connection Times (ms) min mean[+/-sd] median max Connect: 42 60 11.7 58 89 Processing: 89 146 150.2 110 1440 Waiting: 44 69 35.4 61 326 Total: 139 205 152.1 169 1512 Percentage of the requests served within a certain time (ms) 50% 169 66% 182 75% 193 80% 212 90% 246 95% 336 98% 597 99% 1512 100% 1512 (longest request) ...

October 23, 2015 · 2 min · Özkan Pakdil

first jni example

I never tried JNI(Java Native Interface) before. jni is an api for to call native C code from inside a java code. for a principle I dont like this kind of mixed things. calling java inside c# or calling C# code from C++ is always makes hard codes to understand. anyway I was wondering about the performance of printf between java and jni. basically there are 2 codes. one is written in java one is written in C. here is our C code ...

October 10, 2015 · 2 min · Özkan Pakdil

mvn disable checkstyle

Let say you are using windows I know most of developers does that. Especially in the company they work for. Anyway I am trying to build some REST client in standalone jdk. And I have not used it before so I am trying to read examples https://maven.java.net/content/repositories/releases/org/glassfish/jersey/bundles/jersey-examples/2.22/ run them, try to understand. But in windows I am getting this error [ERROR] Failed to execute goal org.apache.maven.plugins:maven-checkstyle-plugin:2.16:check (verify) on project helloworld-webapp: Failed during checkstyle execution: Unable to find suppressions file at location: etc/config/checkstyle-suppressions.xml: Could not find resource 'etc/config/checkstyle-suppressions.xml'. -> [Help 1] First I check pom xmls but could not find the exact point to disable this maven-checkstyle-plugin. I don’t know which super clever engineer enable this in examples and have not tried it under windows. But this kind of errors actually make people to stop learning java. The java language is easy but this environmental problems very frustrating. ...

October 8, 2015 · 1 min · Özkan Pakdil

Java imperative and functional approach performance test 2

another test for imperative code package testarea; import java.util.ArrayList; import java.util.List; import java.util.OptionalDouble; import java.util.stream.Collectors; import java.util.stream.IntStream; public class Test { static int[] array = new int[] { 1, 2, 3, 4, 5, 6, 7, 8, 8, 8, 9, 10 }; private static List<Double> NUMBERS_FOR_AVERAGE = new ArrayList<Double>(); static long startTime, stopTime; public static void main(String[] args) { NUMBERS_FOR_AVERAGE.add(new Double(10)); NUMBERS_FOR_AVERAGE.add(new Double(10)); NUMBERS_FOR_AVERAGE.add(new Double(10)); NUMBERS_FOR_AVERAGE.add(new Double(10)); NUMBERS_FOR_AVERAGE.add(new Double(10)); NUMBERS_FOR_AVERAGE.add(new Double(10)); NUMBERS_FOR_AVERAGE.add(new Double(10)); NUMBERS_FOR_AVERAGE.add(new Double(10)); NUMBERS_FOR_AVERAGE.add(new Double(10)); NUMBERS_FOR_AVERAGE.add(new Double(10)); runImperative(); runFunctional(); runImperative(); runFunctional();runFunctional();runFunctional();runFunctional(); runImperative();runImperative();runImperative();runImperative(); runFunctional(); } private static void runFunctional() { startTime = System.nanoTime(); functionalApproach(); stopTime = System.nanoTime(); System.out.println("F:"+(stopTime - startTime)); } private static void runImperative() { startTime = System.nanoTime(); imperativeApproach(); stopTime = System.nanoTime(); System.out.println("I:"+(stopTime - startTime)); } private static void imperativeApproach() { Double sum = 0d; for (Double vals : NUMBERS_FOR_AVERAGE) { sum += vals; } sum = sum / NUMBERS_FOR_AVERAGE.size(); } private static void functionalApproach() { OptionalDouble average = NUMBERS_FOR_AVERAGE .stream() .mapToDouble(a -> a) .average(); } } here is my output ...

September 20, 2015 · 1 min · Özkan Pakdil

Java imperative and functional approach performance test

I love performance tests. generally I test everything myself if there is no source in the internet I must do it :) today I was reading imperative coding vs functional coding here. it stuck my mind this sentence. they’re probably equally fast and reasonable then I have to try which one is faster. here is the code package testarea; import java.util.stream.Collectors; import java.util.stream.IntStream; public class Test { static int[] array = new int[] { 1, 2, 3, 4, 5, 6, 7, 8, 8, 8, 9, 10 }; static long startTime, stopTime; public static void main(String[] args) { runImperative(); runFunctional(); runImperative(); runFunctional();runFunctional();runFunctional();runFunctional(); runImperative();runImperative();runImperative();runImperative(); runFunctional(); } private static void runFunctional() { startTime = System.nanoTime(); functionalApproach(); stopTime = System.nanoTime(); System.out.println("F:"+(stopTime - startTime)); } private static void runImperative() { startTime = System.nanoTime(); imperativeApproach(); stopTime = System.nanoTime(); System.out.println("I:"+(stopTime - startTime)); } private static void imperativeApproach() { int sum = 0; for (int j = 0; j < array.length; j++) { for (int k = j + 1; k < array.length; k++) { if (k != j && array[k] == array[j]) { sum = sum + array[k]; } } } } private static void functionalApproach() { IntStream.of(array).boxed().collect(Collectors.groupingBy(i -> i)).entrySet().stream() .filter(e -> e.getValue().size() > 1).forEach(e -> { e.getValue().stream().collect(Collectors.summingInt(i -> i)); }); } } here is my output ...

September 19, 2015 · 2 min · Özkan Pakdil