ismop / dap

3 stars 0 forks source link

`threat_levels` REST API is extremally slow #151

Closed mkasztelnik closed 7 years ago

mkasztelnik commented 8 years ago

Test case:

time curl https://dap-dev.moc.ismop.edu.pl/api/v1/threat_levels?private_token=XXX

result:

0,12s user 0,05s system 0% cpu 42,818 total

There is a lot of n+1 queries in DAP logs and additional bug connected with returning a loooong list of threat_level_assessment_runs elements.

mpawlik commented 8 years ago

FYI This might be related to a large amount of new threatassessmentruns, threatassessments and results, which appeared yesterday.

mkasztelnik commented 8 years ago

I'm aware about this drop, but the main problem here is connected with n+1 queries and most probably with bug in number of returned treat_level_assesment_runs.

mpawlik commented 8 years ago

OK, I just wanted to give all involved a 'heads up' ;)

nowakowski commented 8 years ago

@tbartynski This is your code - perhaps you want to pick up this ball? (If not, I can take care of it but am extremely busy with another project right now and will not have time before Thursday...)

tbartynski commented 8 years ago

I'll try to fix it.

tbartynski commented 8 years ago

I improved it a little bit last Wednesday and since then it takes about 2 seconds. I will continue work on this issue.

tbartynski commented 8 years ago

Improved a little more. time curl https://dap-dev.moc.ismop.edu.pl/api/v1/threat_levels?private_token=XXX => real 0m1.276s user 0m0.017s sys 0m0.004s

tbartynski commented 8 years ago

Further improvements were made: time curl https://dap-dev.moc.ismop.edu.pl/api/v1/threat_levels?private_token=XXX => real 0m0.432s user 0m0.003s sys 0m0.008s

server side log: Completed 200 OK in 387ms (Views: 3.5ms | ActiveRecord: 54.6ms)

I guess it's good enough.

mkasztelnik commented 7 years ago

Good for now