view · edit · sidebar · attach · print · history

Index>

20161220-davaz-com-multithreaded

Summary

Commits

Index

Davaz.com should support heavy workload (multithreading)

I think that the problems in davaz.com stem from the fact that before using Rack the App.db_manager variable was thread local, because it was part of the DRbSession. This is no longer the case.There are many expressiong like @session.app.load_thefamily_text

I think the way to go is to move the Rack dependent part into a a new class RackApp and make the old App class a member of the Davaz::Util::Session. But login/logout work. Also I had to change many items in app.rb in a more complicated manner. My idea was simply to replace @db_manager.some_function by @session.db_manager.some_function, but this did not work as @session is often nil, especially when the init states are visited. Do I have a problem in initializing the db_manager/session variable?

This is not as easy as I presumed. Also changed SBSM to allow choice of multi-threading or not (this was easy). Now davaz.ngiger.ch works with multi-threading and serves around 138 requests per second, which is not too bad, and probably more realistic than the numbers returned by davaz.com.

Problem is that the pages do load correctly, e.g. on the main pages the introduction painting is not shown. Neither are the movies displayed.

When breaking in the method init of state/works/movies.rb I get the following results

[14] pry(#<DaVaz::State::Works::Movies>)> @model = @session.app.load_movies().size
=> 0
[15] pry(#<DaVaz::State::Works::Movies>)> @model = @session.db_manager.load_movies().size
=> 5

Why do we find many occurrences of @session.app.load<x>, @session.load<x> and @session.load<x> in src/state? Is there a reason (e.g. that session.app needs a login) to use the different variants or is it only pure conincidence.

Trying to remedy the problem by setting @app.session. Unit tests for davaz.com return just one error in TestShop#test_shopping_cart_calculation_with_publications. I think here I don't pass the correct values for the item via the cookie. But I must change @app.session into a thread specific variable.

In sbsm some unit tests fail, eg. the cookie name is not set correctly. Trying to fix this problem. Was easy to fix. Still having 3 failures in sbsm unit tests.

Davaz.com unit tests have errors in the shop test. They always display only one selected items, whereas before they had no problems to display several selected items. Why? Find error about undefined constant InvalidZone. Where do they come from? sbsm/lib/validator.

Somehow the @session[:cart_items] are no longer persisted. And src/state/communication/shop.rb never finds an old item. Is the session variable updated too often?

Used Thread.current.thread_variable_get/set in sbs/lib/app.rb for the current session. But this does not make it thread safe. davaz.ngiger.ch has login/logout working and is able to add several items to the shop. But in tests this does not work. The pencil drawing for the initial page does not work neither.

After changing the @db_manager in davaz.com/app.rb to a normal variable (no longer threaded), wrk worked again, but only with 28 request/seconds.

view · edit · sidebar · attach · print · history
Page last modified on December 20, 2016, at 05:08 PM