Lyme vs Lamp IV
21st Century Code WorksBest of Erlang - noreply@blogger.com (Benjamin Nortier) - February 22, 2008
The first Lyme vs Lamp comparison is here!
Let’s recap. I have created a single web page, in Lyme and Lamp, based on database queries. The query is from a single table with 1000 “blog” entries, with Id, Timestamp, Title and Content fields. The web page displays the last 10 entries in the table.
I use Tsung to generate users at a progressive rate, starting from 2 users per second up to 1000 users per second:
Subjecting each web application stack to this test, they compare as follows:
But what does it mean?
It looks like Lyme and Lamp perform the same up until 240 seconds into the simulations, which is where we step up from 66 to 100 requests per second. At about that point, Lyme starts to handle less transactions per second, and the mean transaction time increases dramatically.
Where’s the bottleneck? Good question. I suspect it’s in the database query, but this is just a shot in the dark. Why could it be? Well, in the PHP version, it’s very simple to retrieve the last 10 entries:
SELECT * FROM blog_entries ORDER BY `ID` DESC LIMIT 0 , 10
Whereas with Mnesia, I’m not aware of a better way to retrieve the last 10 rows, other than to iterate backwards from the end of the table:
last_N_entries(_Key, 0, Acc) ->
lists:reverse(Acc);
last_N_entries(Key, N, Acc) ->
{atomic, {Entry, NextKey}} =
mnesia:transaction(
fun() ->
[Entry] = mnesia:read({blog_entry, Key}),
NextKey = mnesia:prev(blog_entry, Key),
{Entry, NextKey}
end),
last_N_entries(NextKey, N-1, [Entry|Acc]).
last_N_entries(N) ->
{atomic, LastKey} = mnesia:transaction(fun() -> mnesia:last(blog_entry) end),
last_N_entries(LastKey, N, []).
I might try some different approaches to the Mnesia query (using ram copies instead of disk copies for example), but I’d rather put some effort into making the experiment a bit more focussed. I’d like to especially see what happens when multiple cores are thrown at the problem, but more importantly, what happens when the transactions become concurrent.
I have now realised that this is scenario is essentially a sequential load test, which will not show up Lyme’s strengths. The pages render rather quickly, so there is no concurrent page rendering. Thus, I think the next step should be to create another scenario that will create concurrent page requests…
Categories: Blogs 21st Century Code Works Best of Erlang
Comments
No comments so far, you could be the first.Add comment
Erlang on Twitter
» bagus_erlang (bagus): Bt nieh!! Di sklh…
» VanessaaaZM (Vanessa Zian M): apose? RT @ErNugraha7G Yah mention erlang gadibales @VanessaaaZM
» VanessaaaZM (Vanessa Zian M): pacar aku abel;D RT @annisaH_Ijem jangan samain kakak aku sama si erlang :;pp RT @VanessaaaZM Kaya abel RT @annisaH_Ijem: ngeledek, liat
» ErNugraha7G (ErlAngga™): Yah mention erlang gadibales @VanessaaaZM
» annisaH_Ijem (♡ annisaH~Ijem ♡): jangan samain kakak aku sama si erlang :;pp RT @VanessaaaZM Kaya abel RT @annisaH_Ijem: ngeledek, liat erlangga masa depan tah
» unnali (Len): dear erlang where are my monads yours cheerfully l
» ajfeed (Ajinkya Feed): Erlang: Erlang : UDP socket usage example with gen_udp: submitted by dzysyak [link] [comment] http://t.co/WMpJtySv
» rianindahinyonk (Rian Indah Syafitri): RT @fathiaamandaaa: RT @indrasan: selamat ulang tahun saudara reza erlang @rezasur semoga makin banyak proyek nya ya.
» ericmoritz (Eric Moritz): RT @Burbass: I can now control my Mindstorm Lego car with Erlang. #erlang #mindstorm http://t.co/Jn78yViH
» dalnefre (Dale Schumacher): RT @Burbass: I can now control my Mindstorm Lego car with Erlang. #erlang #mindstorm http://t.co/Jn78yViH
Statistics
Number of aggregated posts: 10503
Number of comments: 2136
Most recent article: May 21, 2012
Latest comments
» Jessica on 30 September 2011: Basho Technologies, Erlang Solutions and Trifork AS Announce Big Data and NoSQL R: yeah of course. I just thought that everything will be just alright and I want to have these kind of…
» DRS786 on 25 May 2012: Poznan Erlang User Group Event: I’m going!
» the tantric way in london on TextOne HD for webOS: Interesting articles are published here. By reading it I acquired great deal of knowledge on various subject. Thank you for…