20120216-update-interaction-algorithm-fix-float-domain-err-add-migel-interactions-mobile-check-threads-oddb_org
<< Masa.20120217-fix-errors-check-threads-problem-oddb_org | Index | Masa.20120215-save-attachment-bsv_xml-fix-ddd_price-interaction-snapback-interaction-key-oddb_org-update-just_medical-decorators-ebps-updated-oddb2tdat-check-grid_c-htmlgrid >>
- Fix interaction algorithm
- Fix FloatDomainError
- Add Migel and Interactions link in mobile look and feel
- Check threads management oddb.org
- Create threads management oddb.org
- Commits
-
- Changed interactions algorithm to search atc-code. When some atc-codes are found, the atc-code(atc_class) that has more packages is taken. (oddb.org)
- Fix FloatDomainError. Division by zero happend when ddd_price was calculated. (oddb.org)
- Added Migel and Interactions in mobile lookandfeel (oddb.org)
- Added thread status information in status log (oddb.org)
Fix interaction algorithm
Commit
Note (for development)
- atc-code corresponding to a substance in interaction_basket is searched in src/view/interactions/resultlist.rb by using @session.search_oddb method and @session.persistent_user_input(:query)
- It is a point that the search is done with NOT substance data, BUT user input data that is used by searching.
- The search word becomes sometimes package name, sometimes Wirkstoff name, etc.
- A substance instance sometimes has some atc-codes (atc_class instances).
- If more than one atc-code is found by @session.search_oddb method, the atc_class that has more packages is taken.
Fix FloatDomainError
Example
Result
Commit
Add Migel and Interactions link in mobile look and feel
URL
Commit
Check threads management oddb.org
Refer to http://dev.ywesee.com/wiki.php/Masa/20111109-testcase-link-format-benchmark-oddbOrg#threads_note
Question
- When and how do the number of threads go up and down in oddb.org?
Commit
Experiment
- /usr/local/lib/ruby/1.9.1/drb/drb.rb
def main_loop
Thread.start(@protocol.accept) do |client|
@grp.add Thread.current
p "@grp = #{@grp},@grp.list.length = #{@grp.list.length}"
def log_size
...
format = "%s %s: sessions: %4i - threads: %4i (%s) Group: %s - memory: %4iMB %s"
...
thread_groups = Thread.list.map{|th| th.group.to_s}.uniq
...
lines.unshift sprintf(format, alarm,
time.strftime('%Y-%m-%d %H:%M:%S'),
sessions, threads, threads_status.join(' '), thread_groups.join(','), mbytes, gc)
Run
/usr/sbin/ab -n 300 -c 100 http://oddb.masa.org/
Console log
"@grp = #<ThreadGroup:0x00000000de1480>,@grp.list.length = 84"
"@grp = #<ThreadGroup:0x00000000de1480>,@grp.list.length = 85"
"@grp = #<ThreadGroup:0x00000000de1480>,@grp.list.length = 86"
"@grp = #<ThreadGroup:0x00000000de1480>,@grp.list.length = 87"
"@grp = #<ThreadGroup:0x00000000de1480>,@grp.list.length = 87"
"@grp = #<ThreadGroup:0x00000000de1480>,@grp.list.length = 88"
"@grp = #<ThreadGroup:0x00000000de1480>,@grp.list.length = 89"
...
Status log
2012-02-16 11:56:24: sessions: 122 - threads: 88 (run:1 sleep:87 aborting:0 dead:0) Group: #<ThreadGroup:0x00000000ddb760>,#<ThreadGroup:0x00000000de1480> - memory: 1112MB
2012-02-16 11:56:18: sessions: 53 - threads: 61 (run:2 sleep:59 aborting:0 dead:0) Group: #<ThreadGroup:0x00000000ddb760>,#<ThreadGroup:0x00000000de1480> - memory: 879MB
2012-02-16 11:56:09: sessions: 0 - threads: 18 (run:2 sleep:16 aborting:0 dead:0) Group: #<ThreadGroup:0x00000000ddb760>,#<ThreadGroup:0x00000000de1480> - memory: 500MB
...
Note
- DRb creates new threads when many accesses happen at the same time
- The number of threads is related to the number of access at the same timne
- The number of sessions is related to the number of user who accesses to oddb.org
- If one user (program) accesses to oddb.org 100 times at the same time, for example using 100 brawsers, the number of sessions is 1 but the number of threads becomes 100.
- After the request task is finished, the thread is killed by DRb and GC deletes the thread.
Create threads management oddb.org
Strategy
- If the number of threads goes over a limit, the next request is passed to a read only server
Milesotones
- how to pass a request to the read only server
- (how to get a response from the read only server)
- which class should check the number of threads regularly
- read only server should be updated
Note
- doc/index.rbx runs on Apache (mod_ruby)
- After the rebooting apache, the number of threads goes down.
- The threads must be created by oddbd, not mod_ruby (apache).
- Which part of oddb application creates a new thread?
- SBSM::Request runs on mod_ruby
- SBSM::Session, which is inherited by ODDB::Session, runs on oddbd
One certain thing
- I can check the number of threads going up in drb.rb#main_loop (/usr/local/lib/ruby/1.9.1/drb/drb.rb)
def main_loop
Thread.start(@protocol.accept) do |client|
@grp.add Thread.current
- The question is: when is the 'Thread.current' is created