Skip to content

Instantly share code, notes, and snippets.

@jramb
Created February 14, 2012 20:01
Show Gist options
  • Save jramb/1829766 to your computer and use it in GitHub Desktop.
Save jramb/1829766 to your computer and use it in GitHub Desktop.
Comparison of Aleph and Ring performance
(ns alephtest.core
(:require [lamina.core :as l])
(:require [aleph.http :as a])
(:require [ring.adapter.jetty :as jetty]))
;; https://github.com/ztellman/aleph
(def counter (atom 0))
(defn say-hello []
(let [n (swap! counter inc)]
;;(Thread/sleep 100)
{:status 200
:headers {"content-type" "text/html"}
:body (str "Hello World: " n)}))
;;;;;;ALEPH;;;;;;;;;
(defn hello-world-aleph [channel request]
(l/enqueue channel
(say-hello)))
(println "Starting aleph server")
(a/start-http-server hello-world-aleph {:port 1337})
;;;;;;;;;;;;;;;;;;;;
;;;;;;RING;;;;;;;;;;
(defn hello-world-ring [req]
(say-hello))
(println "Starting ring server")
(jetty/run-jetty hello-world-ring {:port 8080})
;;;;;;;;;;;;;;;;;;;;
(defproject aleph "1.0.0-SNAPSHOT"
:description "FIXME: write description"
:dependencies [[org.clojure/clojure "1.2.1"]
[aleph "0.2.1-alpha2-SNAPSHOT"]
[ring "1.0.2"]]
:main alephtest.core)
This is ApacheBench, Version 2.3 <$Revision: 655654 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/
Benchmarking localhost (be patient)
Server Software: aleph
Server Hostname: localhost
Server Port: 1337
Document Path: /
Document Length: 20 bytes
Concurrency Level: 100
Time taken for tests: 13.463 seconds
Complete requests: 100000
Failed requests: 0
Write errors: 0
Total transferred: 12600000 bytes
HTML transferred: 2000000 bytes
Requests per second: 7427.72 [#/sec] (mean)
Time per request: 13.463 [ms] (mean)
Time per request: 0.135 [ms] (mean, across all concurrent requests)
Transfer rate: 913.96 [Kbytes/sec] received
Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 6 128.4 0 3008
Processing: 1 7 14.1 7 1544
Waiting: 1 6 14.0 6 1544
Total: 1 13 133.5 7 4548
Percentage of the requests served within a certain time (ms)
50% 7
66% 7
75% 8
80% 8
90% 10
95% 11
98% 14
99% 25
100% 4548 (longest request)
This is ApacheBench, Version 2.3 <$Revision: 655654 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/
Benchmarking localhost (be patient)
Server Software: Jetty(6.1.25)
Server Hostname: localhost
Server Port: 8080
Document Path: /
Document Length: 20 bytes
Concurrency Level: 100
Time taken for tests: 6.527 seconds
Complete requests: 100000
Failed requests: 0
Write errors: 0
Total transferred: 10700000 bytes
HTML transferred: 2000000 bytes
Requests per second: 15321.68 [#/sec] (mean)
Time per request: 6.527 [ms] (mean)
Time per request: 0.065 [ms] (mean, across all concurrent requests)
Transfer rate: 1601.00 [Kbytes/sec] received
Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 4 65.1 2 3006
Processing: 0 3 10.5 2 447
Waiting: 0 2 10.3 1 446
Total: 2 6 66.0 5 3013
Percentage of the requests served within a certain time (ms)
50% 5
66% 5
75% 5
80% 6
90% 6
95% 8
98% 9
99% 9
100% 3013 (longest request)
@lkrubner
Copy link

lkrubner commented Jan 3, 2014

Am I correct in saying that AB only does a HEAD request? If so, that does not seem like a very good way to test Aleph. I would assume that its async nature would only show advantages where some kind of calculation needs to be done, in particular a calculation that can be run across several threads.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment