1

I'm using Queue.js as a libary for loading data from a java RestService.

https://github.com/mbostock/queue

I used the following code:

queue()
    .defer(d3.json, "rest/v1/status/geographicalData")
    .defer(d3.json, "rest/v1/status/geographicalFeatures")
    .defer(d3.json, "rest/v1/status/classes")
    .awaitAll(function(error, results) { console.log("all done!" + results.size)});

On the libary website is the queue method as following decribed:

queue([parallelism]) Constructs a new queue with the specified parallelism. If parallelism is not specified, the queue has infinite parallelism. Otherwise, parallelism is a positive integer. For example, if parallelism is 1, then all tasks will be run in series. If parallelism is 3, then at most three tasks will be allowed to proceed concurrently; this is useful, for example, when loading resources in a web browser.

I have the problem loading the data takes around 3 minutes. After that I tried loading the data synchron. I got the same time result as executing all 3 at once. So I guess they are not loaded parallel. How can I execute the loading of the the elements parallel?

Update

Java Jersey Rest Service threads

Thread before Thread before

Thread after running the website Thread after

I started the rest service in the debugging mode after loading the website I saw multiple threads so the Rest service shouldn't be the problem?

After that I looked at the database connections:

DB before DB before

DB after running the website DB after

After laoding the website I saw multiple open database connections so the database should be also ok?

After that I messerued the loading time with the firefox developer tools, but it took much longer with more data. But if its' runnign parallel it should be finished at the same time?

Browser before (less datasources) Browser before

Browser after (more datascources) Browser after

user2644964
  • 763
  • 2
  • 10
  • 28
  • 1
    Why would the sum change depending on if they are loaded synchronously or in parallel? (what is *sum* in your context?) Can't you just look at the networking tab in the JavaScript console to see how many parallel network requests you have pending? Is it possible that your server-side REST endpoint is only servicing a single connection at a time? – crush Aug 17 '15 at 17:30
  • With sum I meant the time of the execution. It should be faster running it parallel then synchron? I added the screenshot from the network above because I wasn't able to see from the network window if the request is executed parallel. The Rest Service should handle multiple connections because when loading the javascript the Rest services opens immediatly 3 connections to the database. – user2644964 Aug 17 '15 at 17:48
  • 1
    If it immediately opens 3 connections, then that means all 3 are running concurrently, at least from the client-side. It could be your database that is bottlenecking the results. Is the database locking the tables for read access? This sounds more like a server side issue than a client-side issue. – crush Aug 17 '15 at 18:48
  • Also, can you show the code you are using to get the sum of execution times? – crush Aug 17 '15 at 18:54
  • Hi crush I added above the screenshots where you can see that the Jersey Rest service opens multiple threads and database too. I also added the screenshots from a time measurement, so I used no code for that did it with firefox. – user2644964 Aug 18 '15 at 09:11
  • Is there a problem which you can see from the pictures I added in the main text? – user2644964 Aug 18 '15 at 09:17

0 Answers0