0

I'm researching about the access time via http1.0 inner local network. I setup http server at 127.0.0.1:30000, and let curl access to the server. (http server code is implemented on http://www.java2s.com/Code/Java/Network-Protocol/AsimpletinynicelyembeddableHTTP10serverinJava.htm it is very simple program.)

curl -I -0 "http://127.0.0.1:30000/"

It is interesting to note that only first access takes long time. First access takes about 5.0msec, but second access takes 0.7msec. The following access takes only less than 1msec.

I peeked at the packets with WireShark and noticed the almost required time occupied [PSH, ACK] packets from server. Why does such a difference happen?

(I suspected persistent connection make second access fast. But, I experimented http1.0 environment and, persistent connection is defined at http1.1)

Mike Pennington
  • 41,899
  • 19
  • 136
  • 174
tbl
  • 823
  • 1
  • 8
  • 11
  • 1
    Most things are slower on Java for the first time and pretty faster after that. One big cause cause is the JIT. Try running the server in the server VM (using `java -server`). – Gilberto Torrezan Nov 03 '12 at 04:44
  • I tried -server option, but the elapsed time dosen't vary much. -Xint options is same. Though I implemented http server in C language and measured. Every elapsed time is less than about 1.0msec! So, I think this problem depends on Java language, but JIT(byte code caching?) has no relation with in this measurement. Hmm, it's very curious. – tbl Nov 03 '12 at 06:39
  • @GilbertoTorrezan: the JIT usually makes things faster much later than the second time. More something like the 501th time. – JB Nizet Nov 03 '12 at 07:37
  • @JBNizet That depends on the implementation of the VM. You're probably talking about the client Hotspot (Oracle) VM. But there are a lot of VMs out there with several significant differences between them, mainly in regard to JIT compiling. – Gilberto Torrezan Nov 03 '12 at 16:53

0 Answers0