From e7f2f4b0113538ab9383f77b80ad4a9356635ea5 Mon Sep 17 00:00:00 2001 From: Jason Grout Date: Thu, 9 Jun 2011 13:17:25 -0500 Subject: [PATCH 1/4] Implement a ping_json url for webserver. --- web_server.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/web_server.py b/web_server.py index 3c2a8379bd..a551d38577 100644 --- a/web_server.py +++ b/web_server.py @@ -188,6 +188,13 @@ def tabComplete(db,fs): "text":"", "line":code, "block":code, "cursor_pos":request.values["pos"]}}) return jsonify({"completions":xreq.getMessages(header,True)[0]["content"]["matches"]}) +@app.route("/ping_json") +def ping(): + """ + A small url to ping for performance testing + """ + return jsonify({'reply':'pong'}) + @app.route("/config") @get_db def config(db, fs): From 584063d1a0387e0b1f06a0ec66a14b64287697a3 Mon Sep 17 00:00:00 2001 From: Jason Grout Date: Thu, 9 Jun 2011 13:17:58 -0500 Subject: [PATCH 2/4] Implement a ping timing test --- timing/config.cfg | 16 +++++++-------- timing/test_scripts/ping.py | 39 +++++++++++++++++++++++++++++++++++++ 2 files changed, 47 insertions(+), 8 deletions(-) create mode 100644 timing/test_scripts/ping.py diff --git a/timing/config.cfg b/timing/config.cfg index a4d47536ca..a179f878ba 100644 --- a/timing/config.cfg +++ b/timing/config.cfg @@ -6,12 +6,12 @@ results_ts_interval: 5 project_config_script: curl --silent http://boxen.math.washington.edu:5467/config -[user_group-1] -threads: 50 -script: simple_computation.py -script_options: poll_interval=0.1, base_url="http://boxen.math.washington.edu:5467" - - -#[user_group-2] -#threads: 100 +#[simple_computation] +#threads: 50 #script: simple_computation.py +#script_options: poll_interval=0.1, base_url="http://boxen.math.washington.edu:5467" + +[ping] +threads: 50 +script: ping.py +script_options: base_url="http://boxen.math.washington.edu:5467" diff --git a/timing/test_scripts/ping.py b/timing/test_scripts/ping.py new file mode 100644 index 0000000000..717a3ba1d2 --- /dev/null +++ b/timing/test_scripts/ping.py @@ -0,0 +1,39 @@ + +from urllib2 import urlopen +from urllib import urlencode +import json +from random import random +from time import sleep, time +import sys +import numpy +from multiprocessing import Pool +import contextlib +import traceback + +from timing_util import timing, json, json_request + +class Transaction(object): + def __init__(self, **kwargs): + self.custom_timers={} + self.BASE_URL=kwargs.get('base_url', 'http://localhost:8080') + + def run(self): + """ + Simply query for the configuration, which involves a database query and running git on the command line. + """ + response_times=[] + config_url=self.BASE_URL+'/ping_json' + + with timing(response_times): + response = json_request(config_url) + if response['reply']!='pong': + raise ValueError("Reply is not the expected reply") + + self.custom_timers['Response']=response_times + +__all__=['Transaction'] + +if __name__ == '__main__': + trans = Transaction() + trans.run() + print trans.custom_timers From 8f8a890dcf3e826491aa96b87533419c3f9f4546 Mon Sep 17 00:00:00 2001 From: Jason Grout Date: Thu, 9 Jun 2011 13:18:11 -0500 Subject: [PATCH 3/4] Fix default URL for simple_computation --- timing/test_scripts/simple_computation.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/timing/test_scripts/simple_computation.py b/timing/test_scripts/simple_computation.py index 027634f567..800308f1c1 100644 --- a/timing/test_scripts/simple_computation.py +++ b/timing/test_scripts/simple_computation.py @@ -16,7 +16,7 @@ class Transaction(object): def __init__(self, **kwargs): self.custom_timers={} self.MAXRAND=kwargs.get('maxrand', 2**30) - self.BASE_URL=kwargs.get('base_url', 'localhost') + self.BASE_URL=kwargs.get('base_url', 'http://localhost') self.POLL_INTERVAL=kwargs.get('poll_interval', 0.1) def run(self): From 88c45895e46ea53744bb340b71504cdcedbe99ff Mon Sep 17 00:00:00 2001 From: Jason Grout Date: Sat, 11 Jun 2011 11:59:31 -0500 Subject: [PATCH 4/4] Update timing docs with more tools. --- doc/timing.rst | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/doc/timing.rst b/doc/timing.rst index 562a1edf3c..735fe428a9 100644 --- a/doc/timing.rst +++ b/doc/timing.rst @@ -16,3 +16,53 @@ Timing Tests ^^^^^^^^^^^^ .. automodule:: timing.test_scripts.simple_computation + +Notes on Timing +--------------- + +These tests are performed using ``sage.math`` to query +``boxen.math.washington.edu``. + + * When merely pinging the server set up with `300 uwsgi processes + `_, + we are only able to get about 550 requests/sec. This ping + involves only requesting a URL and getting a simple json response + back. Since a computation involves at least two server requests (one to + submit the computation, another to receive the answer), this puts + an upper bound of about 275 computations per second (without + counting for the load of actually doing the computations). + * When we use 400 threads to submit computations to the database and + ask once for the outputs (without actually doing the computation; + no device is running) with `200 uwsgi processes + `_ + and with `300 uwsgi processes + `_, + we get about 500 requests/sec and about 250 computations/sec. The + boxen load went up by about 5 during this test. So it appears + that accessing mongo for submitting requests and for getting + answers does not really slow us down. + * The maximum simple computation (adding two numbers) throughput + I've been able to achieve is around `200 computations per second `_, + but the load on boxen was nearly 35 when this happened. We had + 200 device workers at that time. + + +Other timing tools +^^^^^^^^^^^^^^^^^^ + +* `Grinder `_ +* `JMeter `_ (see also their `list + of tools `_ +* `Apache ab `_:: + + ab -c 1 -n 10000 http://boxen.math.washington.edu:5467/ping_json + +* siege:: + + ./siege -c 20 -b -t 30s http://boxen.math.washington.edu:5467/ping_json + +* `httperf `_:: + + ./httperf --server boxen.math.washington.edu --port 5467 --uri /ping_json www.sagemath.org --num-conns 10000 --timeout 1 --hog + +