• Post Reply Bookmark Topic Watch Topic
  • New Topic

concurrent access to list slowing JSF page load

 
Cedric Bosch
Ranch Hand
Posts: 99
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello, I've some problems with concurrency and JSF.

Under here I've an EJB that makes api calls to different streaming platform (live video) such as twitch and some others.
Then in that EJB I've a list that represent the top15 streams (custom object) from all platform combined. Top 15 means the 15 stream with the most viewers.
This is working fine.

The issue is that if I try to load the page when the computer clock is at 0 seconds, when the scheduled method starts, the page takes a whole more second to load. I would like to know why and how to resolve it. I'm guessing it's because the list is used thus the request has to wait. I'd like not to have to wait for it to be finished. Something like no lock on read or whatever.

I went through the official java concurrency tutorial this evening as most of my questions here revolve around that but I'm honestly still not sure what to do.



// --- Example JSF PAGE:



// --- Where I call the api:

 
Tim Holloway
Bartender
Posts: 18415
58
Android Eclipse IDE Linux
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I probably don't have the whole concept clear. One thing you should try to do is benchmark the EJB as a stand-alone request (without JSF or the webapp), just to ensure that the EJB itself isn't the bottleneck.

Beyond that, the only JSF-specific issue I see is that you are directly querying for the stream list from the dataTable. Since a JSF lifecycle can potentially invoke the "get" method 5 or 6 times, that can amplify any latencies. Plus give you potential data integrity issues if the list is actively changing while this is going on.

A better approach would be to maintain a cached copy of the Stream list in your JSF backing bean and return that instead. It's probably also not a bad idea for the EJB to return a copy of the list rather than the original list, since otherwise the EJB-managed list is potentially exposed to outside modification.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!