title: Performance of com.sun.net.httpserver.HttpServer and HttpURLConnection?
body: <p>I developed a HTTP proxy which makes HTTPS->HTTP conversion, using <code>com.sun.net.httpserver.HttpsServer</code> and <code>HttpURLConnection</code>. Unfortunately it can process only 5 little HTTPS POST request per second. All other requests can't connect to proxy. </p>
  
  <p>I have apache with SSL + tomcat on the same server and it process 50 HTTPS request/sec. Tomcat without apache process 50 HTTP request/second to, so apache with SSL don't slow him at all. If i use my <code>com.sun.net.httpserver.HttpsServer</code> it slows tomcat 10x times! I use it in such way:</p>
  
  <pre><code>HttpsServer server = HttpsServer.create(new InetSocketAddress(config.getInPort()), 0);
  server.createContext("/https", new HttpProxyHandler(config));       
  server.setHttpsConfigurator(new HttpsConfigurator(SSLContext.getDefault()));
  server.setExecutor(null);
  server.start();
  </code></pre>
  
  <p>Handler only send received request to another http URL via <code>HttpURLConnection</code>.</p>
  
  <p>Why the performance of <code>com.sun.net.httpserver.HttpServer</code> is so bad? Is any performance statistic of <code>HttpsServer</code> available? I need very performance server. What if i just read request from SSL socket and write to TCP socket? Will it be suitable for HTTPS request processing?</p>