bcgov / bc-laws-api

Other
4 stars 5 forks source link

Favourites Tree Threshold Limit Break #4

Closed kelpisland closed 8 years ago

kelpisland commented 9 years ago

An idea being explored and shaped. Open for discussion, but may never go anywhere.

Story:

As a product owner I have discovered that the favourites tree is not working correctly as there is a threshold after which the favourites content tree becomes non-functional.

Additional detail:

Goto: http://www.bclaws.ca/civix/content/complete/statreg/?xsl=/templates/browse.xsl and click on Favourites. As a “Content Distributor” the user may already have a favourites tree but when they point a lot of content at it (Goto: http://www.bclaws.ca/civix/content/arch_oic/arc_oic/?xsl=/templates/browse.xsl) the content tree becomes overwhelmed; so as an interim solution it was removed. So it’s not so much that the piece of work is adding documents, this is done through the application layer and consumed through the API interface, but that as I add documents the trees performance degrades to an unacceptable level.

Acceptance criteria:

  1. Javascript tree contains a list of nodes that users can select.
  2. Tree is created using the content API as described: http://www.bclaws.ca/civix/template/complete/api/EP_API_content.html
  3. Selected nodes are stored in a cookie called favIDS, as a list of ancestors separated by comma. Each selection/deselection of a folder/document updates the cookie and adds/deletes the corresponding ancestor to the listTree and should default open to the lowest complete branch. Examples:
    • If “A” is selected in its entirety Tree should open to the “A” folder
    • If “Access to Education” is selected in its entirety Tree should open to “Access to Education”
    • If “Access to Education” and the “P” folder is selected in its entirety the Tree should open to both “Access to Education” and the “P” folder
  4. The list should also be adjusted such that if a parent is selected, the parent ancestor is added to the list and existing children ancestors are deleted.
  5. The Advanced favourite search feature will grab all the ancestors in the cookie. If html5 storage is present, it is used instead of the cookie.
  6. Tree must be able to be cleared using the clear favourites as per: http://www.bclaws.ca/civix/content/complete/statreg/?xsl=/templates/browse.xsl
  7. Tree should not substantially degrade in performance when used against larger document collections such as the Historical OIC collection: http://www.bclaws.ca/civix/content/arch_oic/arc_oic/
  8. Tree should outperform current tree load time by 3X when initially loaded with browser session information cleared. Firefox web-developer profiler will be used to determine the success of the test.

    How to contribute

We will evaluate each pull request and choose the best solution to the issue based on the acceptance criteria. Submit the best solution and you could be paid $1000.

More than one pull request may be considered for payment on this issue.

Please read the Contribution Guidelines for the Terms that set the rules for participation in a Pay for Pull, including how you’ll get paid if you are successful.

Have questions? Please post your questions in the comments section below this issue.

And check out our Partners page for more information on our work.

willwh commented 8 years ago

I started taking a look at this last night.

Much of the load time mentioned in point 8 seems to be from the API itself.

I ran a test with siege, as follows:

siege http:\/\/www.bclaws.ca\/civix\/index\/tree\/statreg --time=1H -l --delay=30 -c 5

My end results looked like this:

Transactions:               1056 hits
Availability:             100.00 %
Elapsed time:            3599.03 secs
Data transferred:        1191.98 MB
Response time:              2.03 secs
Transaction rate:           0.29 trans/sec
Throughput:             0.33 MB/sec
Concurrency:                0.59
Successful transactions:        1056
Failed transactions:               0
Longest transaction:            6.40
Shortest transaction:           0.96

I'd like to do some testing with apache benchmark, as it provides nice graphical output for this sort of thing.

Responses times from the API seem to vary quite a lot, looking at the terminal output from my siege, and I think this warrants a further look!

willwh commented 8 years ago

Ok, I ran another short test with Apache Jmeter

I ran a test with 5 test users, starting a second apart, and stopped the test a little after a minute.

Here's a quick graph of the latency:

bwlaws ca

Bearing in mind, this is just a GET request to http://www.bclaws.ca/civix/index/tree/statreg

I've attached my Test Plan from jmeter here, BC Laws Users.jmx.zip, so you can run the same test if you like.

I'd love to have some conversation about this with someone working on it, is that possible?

AlexStrudwick commented 8 years ago

Hi Willwh,

I would be happy to answer any questions you have. Let's keep the dialogue on here for all participants to see.

Thanks Willwh,

Alex Strudwick Supervisor, Information Systems and Application Development Queen's Printer, Digital Publishing Shared Services BC | Technology, Innovation and Citizens' Services 563 Superior St, Victoria BC V8W 9V7

willwh commented 8 years ago

Hi Alex, Absolutely! So looking at this without considering the client side, can we do anything about the response times and data format returned by this endpoint: http://www.bclaws.ca/civix/index/tree/statreg?

Maybe you could answer the following:

Lastly - is there a repository available with the current implementation that you could publish?

Even if this were just the required libraries, and a sample page wiring things up, I think getting that together would allow others to take a look at this more easily.

I'm definitely not a front end performance expert (which is why my questions are mostly about the back end) - but I think providing the current code implementation for people to poke at with performance tools would make sense. (e.g. Profilng Javascript Performance)

My suspicion here is that XML might just be the wrong choice, in terms of the response body, and also using dhtmlxtree.js, but I would need to do some more digging on this first.

Wow, this turned out much longer I expected.

Thanks for chiming in!!

willwh commented 8 years ago

Just thinking maybe I have not been terribly clear.

I think there are 2 issues we need to solve here:

AlexStrudwick commented 8 years ago

Hi Willwh,

Yes we can provide JSON. We will implement this change and update the API documentation accordingly.

Thanks Willwh, Alex Strudwick Supervisor, Information Systems and Application Development Queen's Printer, Digital Publishing Shared Services BC | Technology, Innovation and Citizens' Services 563 Superior St, Victoria BC V8W 9V7

willwh commented 8 years ago

Great :) About my other question, re: server side caching, is there anything we can do there? :)

AlexStrudwick commented 8 years ago

BC Developer's Exchange test is now complete. Thanks to all for participating.

Thanks everyone, Alex Strudwick Supervisor, Information Systems and Application Development Queen's Printer, Digital Publishing Shared Services BC | Technology, Innovation and Citizens' Services 563 Superior St, Victoria BC V8W 9V7

AlexStrudwick commented 8 years ago

Hi everyone,

We are looking into the server side performance. We will post back with results/changes.

Thanks everyone, Alex Strudwick Supervisor, Information Systems and Application Development Queen's Printer, Digital Publishing Shared Services BC | Technology, Innovation and Citizens' Services 563 Superior St, Victoria BC V8W 9V7

AlexStrudwick commented 8 years ago

Hello everyone,

Please let me know if you have any technical questions regarding this project. I would be happy to answer your questions or to hand them off to someone who can.

Thanks,

Alex Strudwick Supervisor, Information Systems and Application Development Queen's Printer, Digital Publishing Shared Services BC | Technology, Innovation and Citizens' Services 563 Superior St, Victoria BC V8W 9V7

AmadeusW commented 8 years ago

What are the requirements for the server side? Do developers need to sign an NDA to get access to the server side code?

Maxwolf commented 8 years ago

I am also interested in what would be required to work on the server/client software. In an ideal situation we would run all of this as a copy on our machines to get the data working exactly the way you want then you could take pull requests for each project respectively.

AlexStrudwick commented 8 years ago

Hi everyone,

The solution to this task should be completed without server side changes. Our public facing API provides access to the full source XML used to create the tree.

For example, the Legislative Catalogue found here: http://www.bclaws.ca/civix/content/lc/?xsl=/templates/browse.xsl

By removing the query variables you can see a listing of each index in this aspect: http://www.bclaws.ca/civix/content/lc/

You can then call the API for each /root/index/CIVIX_DOCUMENT_ID: http://www.bclaws.ca/civix/index/tree/{CIVIX_DOCUMENT_ID} e.g. http://www.bclaws.ca/civix/index/tree/statreg http://www.bclaws.ca/civix/index/tree/psl etc...

And build your favorites tree from the combined xml.

Thanks, Alex Strudwick Supervisor, Information Systems and Application Development Queen's Printer, Digital Publishing Shared Services BC | Technology, Innovation and Citizens' Services 563 Superior St, Victoria BC V8W 9V7

willwh commented 8 years ago

@AlexStrudwick Any updates on JSON output of the data?

AlexStrudwick commented 8 years ago

@willwh

Sorry nothing yet. I should be able to get something to you by the end of next week.

Thanks, Alex Strudwick Supervisor, Information Systems and Application Development Queen's Printer, Digital Publishing Shared Services BC | Technology, Innovation and Citizens' Services 563 Superior St, Victoria BC V8W 9V7

willwh commented 8 years ago

@AlexStrudwick sounds great :)

My one concern with the performance portion of this ticket is still the API response times.... re: my initial notes in this issue. I wonder if anything can be done there?

AlexStrudwick commented 8 years ago

@willwh

We are working on that as we speak.

holmberd commented 8 years ago

I'm taking a look at it.

AlexStrudwick commented 8 years ago

This issue has gone stagnant and will be closed.