[Ur] Performance of Ur/Web in a live site

Chris Double chris.double at double.co.nz
Wed Jun 8 09:58:51 EDT 2011


I rewrote an existing web application of mine in Ur/Web last weekend
to see how it performed vs the current one. The application is in a
similar domain to the one which I posted about a few days ago (virtual
currency). This one is a 'mining pool' for namecoin (or any e-currency
that uses the bitcoin proof of work system).

A mining pool is basically a JSON-RPC proxy. It receives JSON-RPC
requests (HTTP requests containing JSON data via POST) from clients
and forwards them to the main mining program. It gets the result
(which is JSON) and modifies it before returning the data back to the
original client. It keeps statistics of the requests in a database.
One particular JSON-RPC request contains a 'result'. The Ur/Web
application checks to make sure the result is valid, performing SHA256
hashes on it, checking it hasn't been submitted multiple times, or for
old out of date information, and then passes it on to the main server.
If the server confirms the result then the application does more
database operations to update stats, compute payouts, etc.

The proxy itself is Ur/Web code and the SHA256 and result checking is
done using the FFI. The web interface showing the current pool status
and for paying out to clients is Ur/Web too. This also uses
uw_register_transactional to do the payouts as it's a non-reversible
payment.

The original pool server I wrote in another language struggled at
about 20 work requests per second. Once it hit 30 it would peg the
server at 100% CPU and eventually fall over. The Ur/Web version has
hit 70 work requests per second and averages 40-50. This is using very
low CPU and looks to be able to scale higher quite nicely. Previously
the dealing with the web requests was the bottleneck. With this
version it's mainly the database that's using more of the CPU. Ur/Web
sits with very low memory and handles it fine. I'm very happy with it.

You can see the stats (updated every 30 seconds using Ur/Web's
functional reactive code) in the front page of the site here:
http://bitparking.com/pool


Chris.
-- 
http://www.bluishcoder.co.nz



More information about the Ur mailing list