title: AWS Athena concurrency limits: Number of submitted queries VS number of running queries
body: <p>According to <a href="https://docs.aws.amazon.com/athena/latest/ug/service-limits.html" rel="noreferrer">AWS Athena limitations</a> you can submit up to 20 queries of the same type at a time, but it is a soft limit and can be increased on request. I use <code>boto3</code> to interact with Athena and my script submits 16 CTAS queries each of which takes about 2 minutes to finish. In a AWS account, it is only me who is using Athena service. However, when I look at the state of queries through console I see that only a few of queries (5 on average) are actually being executed despite all of them being in state <code>Running</code>. Here is what would normally see in Athena hisotry tab:</p>
  
  <p><img src="https://i.stack.imgur.com/e8mIn.png" alt="Athena hisotry tab"></p>
  
  <p>I understand that, after I submit queries to Athena, it processes the queries by assigning resources based on the overall service load and the amount of incoming requests. But I tried to run them at different days and hours, still would get about 5 queries being executed at the same time.</p>
  
  <p>So my question is this how it supposed to be? If it is then what is the point of being able to submit up to 20 queries if roughly 15 of them would be idling and waiting for available slots.</p>
  
  <h2>Update 2019-09-26</h2>
  
  <p>Just stumbled across HIVE CONNECTOR in presto documentation, which has a section <a href="https://prestosql.io/docs/current/connector/hive.html#aws-glue-catalog-configuration-properties" rel="noreferrer">AWS Glue Catalog Configuration Properties</a>. There we can see</p>
  
  <blockquote>
    <p><code>hive.metastore.glue.max-connections</code>: Max number of concurrent connections to Glue (defaults to 5).</p>
  </blockquote>
  
  <p>This got me wonder if it has something to do with my issue. As I understand, Athena is simply a Presto that runs on EMR cluster which is configured to use AWS Glue Data Catalog as the Metastore. </p>
  
  <p>So what if my issue comes from the fact that EMR cluster for Athena simply uses default value for concurrent connections to Glue, which is 5 which and is exactly of how many concurrent queries are actually getting executed (on average) in my case.</p>
  
  <h2>Update 2019-11-27</h2>
  
  <p>The Athena team recently deployed a host of new functionality for Athena. although <code>QUEUED</code> has been in the state enum for some time is hasn't been used until now. So now I get, correct info about query state in a history tab, but everything else remains the same.</p>
  
  <p><a href="https://i.stack.imgur.com/IKKOa.png" rel="noreferrer"><img src="https://i.stack.imgur.com/IKKOa.png" alt="enter image description here"></a></p>
  
  <p>Also, <a href="https://stackoverflow.com/questions/59072615/how-to-speed-up-amazon-athena-query-executions">another post</a> was published with similar problem. </p>