Sudden performance drop going from 1024 to 1025 bytes
This turned out to be related to libcurl's default "Expect: 100-continue" header.
I am running a dev server using runserver. It exposes a json POST route. Consistently I'm able to reproduce the following performance artifact - if request payload is <= 1024 bytes it runs in 30ms, but if it is even 1025 bytes it takes more than 1000ms.
I've profiled and the profile points to rest_framework/parsers.py JSONParser.parse() -> django/http/request HTTPRequest.read() -> django/core/handlers/wsgi.py LimitedStream.read() -> python2.7/socket.py _fileobject.read()
Not sure if there is some buffer issue. I'm using Python 2.7 on Mac os x 10.10.