Skip to content

Instantly share code, notes, and snippets.

@minrk
Created June 7, 2013 20:16
Show Gist options
  • Save minrk/5732094 to your computer and use it in GitHub Desktop.
Save minrk/5732094 to your computer and use it in GitHub Desktop.
Display the source blob
Display the rendered blob
Raw
{
"metadata": {
"name": "REST demo"
},
"nbformat": 3,
"nbformat_minor": 0,
"worksheets": [
{
"cells": [
{
"cell_type": "heading",
"level": 1,
"metadata": {},
"source": [
"Concurrent REST requests with threads"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"This is a simple demo of using threads for concurrent consumption of a REST API.\n",
"\n",
"First, we define our simple function for processing a single resource ID.\n",
"It has three basic steps:\n",
"\n",
"1. GET the record\n",
"2. parse / process it\n",
"3. PUT to update the record"
]
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"import requests\n",
"\n",
"url_t = \"http://localhost:8000/records/%i\"\n",
"\n",
"def process_id(id):\n",
" \"\"\"process a single ID\"\"\"\n",
" # fetch the data\n",
" r = requests.get(url_t % id)\n",
" # parse the JSON reply\n",
" data = r.json()\n",
" # and update some data with PUT\n",
" requests.put(url_t % id, data=data)\n",
" return data\n",
" "
],
"language": "python",
"metadata": {},
"outputs": [],
"prompt_number": 1
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Our dummy webservice is just a simple REST service that serves up the `/usr/share/dict/words` word list:"
]
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"import os\n",
"ip = get_ipython()\n",
"print ip.pycolorize(open(os.path.expanduser(\"~/temp/echo.py\")).read())"
],
"language": "python",
"metadata": {},
"outputs": [
{
"output_type": "stream",
"stream": "stdout",
"text": [
"\u001b[1;34m\"\"\"Simple dummy REST webservice\u001b[0m\n",
"\u001b[1;34m\u001b[0m\n",
"\u001b[1;34mIncludes artificial delay in requests to allow simulation of concurrent access.\u001b[0m\n",
"\u001b[1;34m\"\"\"\u001b[0m\u001b[1;33m\u001b[0m\n",
"\u001b[1;33m\u001b[0m\u001b[1;32mimport\u001b[0m \u001b[0mjson\u001b[0m\u001b[1;33m\u001b[0m\n",
"\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\n",
"\u001b[1;33m\u001b[0m\u001b[1;32mfrom\u001b[0m \u001b[0mtornado\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mhttpserver\u001b[0m \u001b[1;32mimport\u001b[0m \u001b[0mHTTPServer\u001b[0m\u001b[1;33m\u001b[0m\n",
"\u001b[1;33m\u001b[0m\u001b[1;32mfrom\u001b[0m \u001b[0mtornado\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mioloop\u001b[0m \u001b[1;32mimport\u001b[0m \u001b[0mIOLoop\u001b[0m\u001b[1;33m\u001b[0m\n",
"\u001b[1;33m\u001b[0m\u001b[1;32mfrom\u001b[0m \u001b[0mtornado\u001b[0m \u001b[1;32mimport\u001b[0m \u001b[0mweb\u001b[0m\u001b[1;33m\u001b[0m\n",
"\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\n",
"\u001b[1;33m\u001b[0m\u001b[1;32mfrom\u001b[0m \u001b[0mtornado\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0moptions\u001b[0m \u001b[1;32mimport\u001b[0m \u001b[0mdefine\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0moptions\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mparse_command_line\u001b[0m\u001b[1;33m\u001b[0m\n",
"\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\n",
"\u001b[1;33m\u001b[0m\u001b[0mdefine\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;34m\"port\"\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mdefault\u001b[0m\u001b[1;33m=\u001b[0m\u001b[1;36m8000\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mhelp\u001b[0m\u001b[1;33m=\u001b[0m\u001b[1;34m\"run on the given port\"\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mtype\u001b[0m\u001b[1;33m=\u001b[0m\u001b[0mint\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\n",
"\u001b[1;33m\u001b[0m\u001b[0mdefine\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;34m\"delay\"\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mdefault\u001b[0m\u001b[1;33m=\u001b[0m\u001b[1;36m0.1\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mhelp\u001b[0m\u001b[1;33m=\u001b[0m\u001b[1;34m\"artificial delay for GET requests\"\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mtype\u001b[0m\u001b[1;33m=\u001b[0m\u001b[0mfloat\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\n",
"\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\n",
"\u001b[1;33m\u001b[0m\u001b[1;31m# load simple word list, or RESTful data\u001b[0m\u001b[1;33m\u001b[0m\n",
"\u001b[1;33m\u001b[0m\u001b[0mwords\u001b[0m \u001b[1;33m=\u001b[0m \u001b[1;33m[\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m\u001b[0m\n",
"\u001b[1;33m\u001b[0m\u001b[1;32mwith\u001b[0m \u001b[0mopen\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;34m\"/usr/share/dict/words\"\u001b[0m\u001b[1;33m)\u001b[0m \u001b[1;32mas\u001b[0m \u001b[0mf\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\n",
"\u001b[1;33m\u001b[0m \u001b[1;32mfor\u001b[0m \u001b[0mline\u001b[0m \u001b[1;32min\u001b[0m \u001b[0mf\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\n",
"\u001b[1;33m\u001b[0m \u001b[0mwords\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mappend\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mline\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mstrip\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\n",
"\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\n",
"\u001b[1;33m\u001b[0m\u001b[1;32mclass\u001b[0m \u001b[0mMainHandler\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mweb\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mRequestHandler\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\n",
"\u001b[1;33m\u001b[0m \u001b[1;33m\u001b[0m\n",
"\u001b[1;33m\u001b[0m \u001b[1;33m@\u001b[0m\u001b[0mweb\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0masynchronous\u001b[0m\u001b[1;33m\u001b[0m\n",
"\u001b[1;33m\u001b[0m \u001b[1;32mdef\u001b[0m \u001b[0mget\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mself\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0marg\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\n",
"\u001b[1;33m\u001b[0m \u001b[0mindex\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mint\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0marg\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\n",
"\u001b[1;33m\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mwrite\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mjson\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mdumps\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mdict\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mindex\u001b[0m\u001b[1;33m=\u001b[0m\u001b[0mindex\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mword\u001b[0m\u001b[1;33m=\u001b[0m\u001b[0mwords\u001b[0m\u001b[1;33m[\u001b[0m\u001b[0mindex\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\n",
"\u001b[1;33m\u001b[0m \u001b[1;31m# artificial delay for finish:\u001b[0m\u001b[1;33m\u001b[0m\n",
"\u001b[1;33m\u001b[0m \u001b[0mloop\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mIOLoop\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0minstance\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\n",
"\u001b[1;33m\u001b[0m \u001b[0mloop\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0madd_timeout\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mloop\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mtime\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m)\u001b[0m \u001b[1;33m+\u001b[0m \u001b[0moptions\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mdelay\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mfinish\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\n",
"\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\n",
"\u001b[1;33m\u001b[0m \u001b[1;32mdef\u001b[0m \u001b[0mput\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mself\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0marg\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\n",
"\u001b[1;33m\u001b[0m \u001b[1;34m\"\"\"put does nothing\"\"\"\u001b[0m\u001b[1;33m\u001b[0m\n",
"\u001b[1;33m\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mwrite\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mjson\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mdumps\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mdict\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mstatus\u001b[0m\u001b[1;33m=\u001b[0m\u001b[1;34m\"ok\"\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\n",
"\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\n",
"\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\n",
"\u001b[1;33m\u001b[0m\u001b[1;32mdef\u001b[0m \u001b[0mmain\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\n",
"\u001b[1;33m\u001b[0m \u001b[0mparse_command_line\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\n",
"\u001b[1;33m\u001b[0m \u001b[0mapplication\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mweb\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mApplication\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m[\u001b[0m\u001b[1;33m\u001b[0m\n",
"\u001b[1;33m\u001b[0m \u001b[1;33m(\u001b[0m\u001b[1;34mr\"/records/(.*)\"\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mMainHandler\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m,\u001b[0m\u001b[1;33m\u001b[0m\n",
"\u001b[1;33m\u001b[0m \u001b[1;33m]\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\n",
"\u001b[1;33m\u001b[0m \u001b[0mhttp_server\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mHTTPServer\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mapplication\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\n",
"\u001b[1;33m\u001b[0m \u001b[0mhttp_server\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mlisten\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0moptions\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mport\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\n",
"\u001b[1;33m\u001b[0m \u001b[0mIOLoop\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0minstance\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mstart\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\n",
"\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\n",
"\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\n",
"\u001b[1;33m\u001b[0m\u001b[1;32mif\u001b[0m \u001b[0m__name__\u001b[0m \u001b[1;33m==\u001b[0m \u001b[1;34m\"__main__\"\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\n",
"\u001b[1;33m\u001b[0m \u001b[0mmain\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
"\n"
]
}
],
"prompt_number": 2
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Now fetch some answers from the service (it should take a bit more than N/10 seconds, since we are using an artificial delay of 100ms)."
]
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"%time answers = [ process_id(n) for n in range(32) ]\n",
"answers"
],
"language": "python",
"metadata": {},
"outputs": [
{
"output_type": "stream",
"stream": "stdout",
"text": [
"CPU times: user 116 ms, sys: 16.2 ms, total: 133 ms\n",
"Wall time: 3.41 s\n"
]
},
{
"metadata": {},
"output_type": "pyout",
"prompt_number": 3,
"text": [
"[{u'index': 0, u'word': u'A'},\n",
" {u'index': 1, u'word': u'a'},\n",
" {u'index': 2, u'word': u'aa'},\n",
" {u'index': 3, u'word': u'aal'},\n",
" {u'index': 4, u'word': u'aalii'},\n",
" {u'index': 5, u'word': u'aam'},\n",
" {u'index': 6, u'word': u'Aani'},\n",
" {u'index': 7, u'word': u'aardvark'},\n",
" {u'index': 8, u'word': u'aardwolf'},\n",
" {u'index': 9, u'word': u'Aaron'},\n",
" {u'index': 10, u'word': u'Aaronic'},\n",
" {u'index': 11, u'word': u'Aaronical'},\n",
" {u'index': 12, u'word': u'Aaronite'},\n",
" {u'index': 13, u'word': u'Aaronitic'},\n",
" {u'index': 14, u'word': u'Aaru'},\n",
" {u'index': 15, u'word': u'Ab'},\n",
" {u'index': 16, u'word': u'aba'},\n",
" {u'index': 17, u'word': u'Ababdeh'},\n",
" {u'index': 18, u'word': u'Ababua'},\n",
" {u'index': 19, u'word': u'abac'},\n",
" {u'index': 20, u'word': u'abaca'},\n",
" {u'index': 21, u'word': u'abacate'},\n",
" {u'index': 22, u'word': u'abacay'},\n",
" {u'index': 23, u'word': u'abacinate'},\n",
" {u'index': 24, u'word': u'abacination'},\n",
" {u'index': 25, u'word': u'abaciscus'},\n",
" {u'index': 26, u'word': u'abacist'},\n",
" {u'index': 27, u'word': u'aback'},\n",
" {u'index': 28, u'word': u'abactinal'},\n",
" {u'index': 29, u'word': u'abactinally'},\n",
" {u'index': 30, u'word': u'abaction'},\n",
" {u'index': 31, u'word': u'abactor'}]"
]
}
],
"prompt_number": 3
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Now we define a function that calls our single-id function for a range of IDs.\n",
"Simple enough."
]
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"def process_id_range(id_range, store=None):\n",
" \"\"\"process a number of ids, storing the results in a dict\"\"\"\n",
" if store is None:\n",
" store = {}\n",
" for id in id_range:\n",
" store[id] = process_id(id)\n",
" return store"
],
"language": "python",
"metadata": {},
"outputs": [],
"prompt_number": 4
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"This does the same thing as the list comprehension above (but with a dict)\n",
"in a single function call:"
]
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"%time s = process_id_range(range(32));\n",
"s"
],
"language": "python",
"metadata": {},
"outputs": [
{
"output_type": "stream",
"stream": "stdout",
"text": [
"CPU times: user 118 ms, sys: 15.6 ms, total: 134 ms\n",
"Wall time: 3.42 s\n"
]
},
{
"metadata": {},
"output_type": "pyout",
"prompt_number": 5,
"text": [
"{0: {u'index': 0, u'word': u'A'},\n",
" 1: {u'index': 1, u'word': u'a'},\n",
" 2: {u'index': 2, u'word': u'aa'},\n",
" 3: {u'index': 3, u'word': u'aal'},\n",
" 4: {u'index': 4, u'word': u'aalii'},\n",
" 5: {u'index': 5, u'word': u'aam'},\n",
" 6: {u'index': 6, u'word': u'Aani'},\n",
" 7: {u'index': 7, u'word': u'aardvark'},\n",
" 8: {u'index': 8, u'word': u'aardwolf'},\n",
" 9: {u'index': 9, u'word': u'Aaron'},\n",
" 10: {u'index': 10, u'word': u'Aaronic'},\n",
" 11: {u'index': 11, u'word': u'Aaronical'},\n",
" 12: {u'index': 12, u'word': u'Aaronite'},\n",
" 13: {u'index': 13, u'word': u'Aaronitic'},\n",
" 14: {u'index': 14, u'word': u'Aaru'},\n",
" 15: {u'index': 15, u'word': u'Ab'},\n",
" 16: {u'index': 16, u'word': u'aba'},\n",
" 17: {u'index': 17, u'word': u'Ababdeh'},\n",
" 18: {u'index': 18, u'word': u'Ababua'},\n",
" 19: {u'index': 19, u'word': u'abac'},\n",
" 20: {u'index': 20, u'word': u'abaca'},\n",
" 21: {u'index': 21, u'word': u'abacate'},\n",
" 22: {u'index': 22, u'word': u'abacay'},\n",
" 23: {u'index': 23, u'word': u'abacinate'},\n",
" 24: {u'index': 24, u'word': u'abacination'},\n",
" 25: {u'index': 25, u'word': u'abaciscus'},\n",
" 26: {u'index': 26, u'word': u'abacist'},\n",
" 27: {u'index': 27, u'word': u'aback'},\n",
" 28: {u'index': 28, u'word': u'abactinal'},\n",
" 29: {u'index': 29, u'word': u'abactinally'},\n",
" 30: {u'index': 30, u'word': u'abaction'},\n",
" 31: {u'index': 31, u'word': u'abactor'}}"
]
}
],
"prompt_number": 5
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"And finally the real point of this whole exercise,\n",
"we can partition a list of IDs and assign sub-lists to threads,\n",
"so that we can have some requests running concurrently."
]
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"from threading import Thread"
],
"language": "python",
"metadata": {},
"outputs": [],
"prompt_number": 6
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"def threaded_process(nthreads, id_range):\n",
" \"\"\"process the id range in a specified number of threads\"\"\"\n",
" store = {}\n",
" threads = []\n",
" # create the threads\n",
" for i in range(nthreads):\n",
" ids = id_range[i::nthreads]\n",
" t = Thread(target=process_id_range, args=(ids,store))\n",
" threads.append(t)\n",
" \n",
" # start the threads\n",
" [ t.start() for t in threads ]\n",
" # wait for the threads to finish\n",
" [ t.join() for t in threads ]\n",
" return store\n"
],
"language": "python",
"metadata": {},
"outputs": [],
"prompt_number": 7
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"If we test this, we will see that adding threads allows this to complete faster.\n",
"Given the nature of the dummy workload, this should actually scale to almost 100 threads."
]
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"import time"
],
"language": "python",
"metadata": {},
"outputs": [],
"prompt_number": 8
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"id_range = range(100)\n",
"tic = time.time()\n",
"reference = process_id_range(id_range)\n",
"reftime = time.time() - tic\n",
"print 1, reftime\n",
"\n",
"nlist = [1,2,4,8,16,32,64]\n",
"tlist = [reftime]\n",
"for nthreads in nlist[1:]:\n",
" tic = time.time()\n",
" ans = threaded_process(nthreads, id_range)\n",
" toc = time.time()\n",
" print nthreads, toc-tic\n",
" assert ans == reference\n",
" tlist.append(toc-tic)"
],
"language": "python",
"metadata": {},
"outputs": [
{
"output_type": "stream",
"stream": "stdout",
"text": [
"1 10.8778159618\n",
"2"
]
},
{
"output_type": "stream",
"stream": "stdout",
"text": [
" 5.70237803459\n",
"4"
]
},
{
"output_type": "stream",
"stream": "stdout",
"text": [
" 3.02138209343\n",
"8"
]
},
{
"output_type": "stream",
"stream": "stdout",
"text": [
" 1.79273200035\n",
"16"
]
},
{
"output_type": "stream",
"stream": "stdout",
"text": [
" 1.00950598717\n",
"32"
]
},
{
"output_type": "stream",
"stream": "stdout",
"text": [
" 0.682367086411\n",
"64"
]
},
{
"output_type": "stream",
"stream": "stdout",
"text": [
" 0.624274015427\n"
]
}
],
"prompt_number": 9
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"%pylab inline"
],
"language": "python",
"metadata": {},
"outputs": [
{
"output_type": "stream",
"stream": "stdout",
"text": [
"\n",
"Welcome to pylab, a matplotlib-based Python environment [backend: module://IPython.kernel.zmq.pylab.backend_inline].\n",
"For more information, type 'help(pylab)'.\n"
]
}
],
"prompt_number": 10
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"plt.loglog(nlist, [ len(id_range) / t for t in tlist], '-o')\n",
"plt.xlabel(\"n threads\")\n",
"plt.ylabel(\"requests / sec\");"
],
"language": "python",
"metadata": {},
"outputs": [
{
"metadata": {},
"output_type": "display_data",
"png": "iVBORw0KGgoAAAANSUhEUgAAAm4AAAGOCAYAAAAuBI8MAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAIABJREFUeJzt3Xt81PWd7/H3JJPJdRKScA23GCAECIhBEAIYaEDBViWt\nXbsIgtb1US/VPXtKq0dsu8Vz9Jyt7amtBfs4u8pF6BYslO1uCfeUFWqxsOViTDAJYEQC5Da5Zybz\nO38Epk4JChjmN9/k9fzHzEwuH3no8Mrv8v06LMuyBAAAgLAXYfcAAAAAuDqEGwAAgCGcdg/QlfPn\nz+vXv/61JGnSpEm69dZbbZ4IAADAfo5wvsato6NDGzZs0KJFi+weBQAAwHZhe6q0oqJCL7zwgmbM\nmGH3KAAAAGEhrI+4tbe3a926dXr44YftHgUAAMB2IbvGz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a2uXnW5YV+NjhcGj+/PlyOjvf+saPH6933nkn8Hrfvn01ceJE\nSdL777+vDz/8UD/5yU8Cr7e3t2vEiBGSpMjISP3rv/6rKisrZVmW6uvrVVdXp8bGRvl8Pk2bNi3w\ndZmZmZo1a1bg8cSJE/XDH/5QkyZN0s0336y4uLjP+acCoLcg3AAYJTY2NuhxVFRUUJxdy9c7nc6g\nr3W5XIGPHQ6HbrrpJn3nO9/p8vv84Ac/0P33368lS5ZIkp577rnA13XFsqzAz3riiSdUWVmpY8eO\n6eWXX9bChQs1adKkq/53ANB7cXMCgB4rKioqcH3atcrKytKZM2d0+PBhSZLf79cvf/lLlZeXS5Lq\n6uo0atQoSdLp06d1+vRpSdLw4cPlcrm0f//+wPcqLS3V3r175XA41N7erh07digtLU3z5s1Tbm6u\nKioqPs+/JoBehCNuAIxyLUt63HrrrfrRj36kP//5z4EjY1f7vaOjo/Xss89qzZo12rJli7xer7Kz\ns5Weni5JevDBB7VixQq53W4NHjxYN998cyASv/Wtb2nt2rUqLCyU3+/XwIEDNXv2bEmdR/UuXLig\nZcuWKT4+XvHx8YEbJwDgszisaznHAAAAANtwqhQAAMAQhBsAAIAhCDcAAABDEG4AAACGINwAAAAM\nQbgBAAAYgnADAAAwBOEGAABgiP8PN7XBlv+F9OsAAAAASUVORK5CYII=\n",
"text": [
"<matplotlib.figure.Figure at 0x108ba6dd0>"
]
}
],
"prompt_number": 11
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"And, logically enough, we peak around 50 threads, because anything between 50 and 99 threads\n",
"there is at least one thread that processes two requests.\n",
"All the other threads end up waiting."
]
}
],
"metadata": {}
}
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment