We are building a business intelligence system, and we have a huge PostgreSQL Database (DB) where we make all the info processing, and a Redshift Data Warehouse (DWH) where we store the data and execute queries.
The backend is built in Java Server Faces (JSF), and before, the queries were made lineal. Some views were taking more than a minute to finish queries and load the info in screen, so we decided to use threads in Java and make the queries asynchronous.
So we have prepared the necessary queries for each view to be run parallel from our EC2 app machine, to our Redshift DWH, and run the threads but views still take long to load, sometimes even longer.
We found in the documentation:
http://docs.aws.amazon.com/redshift/latest/dg/cm-c-executing-queries.html
http://docs.aws.amazon.com/redshift/latest/dg/c_troubleshooting_query_performance.html
http://docs.aws.amazon.com/redshift/latest/dg/r_wlm_query_slot_count.html
That redshift by default receive 5 queries at same time, but that is a setting we can change.
There are 3 main things to take into account: query slots, concurrency and queues. We have understood this:
A queue is like a thread in Java. A query arrives and is designated to the "less loaded" queue, and it waits for its turn to be resolved. We can have as many queues as we like. A queue has some memory allocated (we guess divided equally?) In a queue we can assign user groups or queries groups. But in short-term, that's a lot of classification work in our queries we can't do right now.
A concurrency is the amount of queries that a queue can run in parallel. By default is 5.
And a query slot is the amount of memory a query can use. It's related to concurrency as we understood it. The more concurrency a queue has, the less memory in each query slot it has.
We have tried to have 3 queues, each one with concurrecy 5, but performance still slow.
So, if we have understood correctly, having that some viewes make up to 25-28 queries, and the total amount of loading time is around 60s, how can we leave the settings the queries can be resolved faster?