# About Random Slow Query Timeouts in Neo4j

**URL:** <https://community.neo4j.com/t/about-random-slow-query-timeouts-in-neo4j/69535>\
**Category:** Java\
**Created:** [September 3, 2024, 9:40am UTC](https://community.neo4j.com/t/about-random-slow-query-timeouts-in-neo4j/69535 "2024-09-03T09:40:21Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![3306612685](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/3306612685/32/32579_2.png) [@3306612685](https://community.neo4j.com/u/3306612685)\
**Post date:** [September 3, 2024, 9:40am UTC](https://community.neo4j.com/t/about-random-slow-query-timeouts-in-neo4j/69535/1 "2024-09-03T09:40:21Z")

</div>

"I am encountering timeout issues while using Neo4j 3.5.35. Here's how my Java code initializes Neo4j:

```auto
try {  
    Config config = Config.builder()  
            .withMaxConnectionPoolSize(1000)  
            .withConnectionAcquisitionTimeout(30, TimeUnit.SECONDS)  
            .withConnectionTimeout(30, TimeUnit.SECONDS)  
            .withConnectionLivenessCheckTimeout(30, TimeUnit.SECONDS)  
            .build();  
    this.driver = GraphDatabase.driver(uri/*"bolt://localhost:7687"*/,   
            AuthTokens.basic(username/*"neo4j"*/, pass/*"123456"*/), config);  

    this.config = TransactionConfig.builder()  
            .withTimeout(Duration.ofMinutes(3))  
            .build();  

} catch (Throwable e) {  
    e.printStackTrace();  
}  

```

In my `neo4j.conf`, I have the following configuration:

```auto
dbms.connector.bolt.thread_pool_min_size=10  
dbms.connector.bolt.thread_pool_max_size=2000  
dbms.memory.heap.initial_size=8g  
dbms.memory.heap.max_size=16g  

```

Neo4j is running inside a Docker container on a server (CPU: 40 cores, 80 threads, Intel(R) Xeon(R) Silver 4114 CPU @ 2.20GHz, 125GB RAM, SSD). There are approximately 10 million nodes in the Neo4j graph.

During my use, some queries occasionally become very slow, causing timeout errors. These errors are recorded in the `debug.log`, as shown below:

```auto
2024-09-02 19:17:56.384+0000 ERROR [o.n.b.t.p.HouseKeeper] Fatal error occurred when handling a client connection: [id: 0x102cac0f, L:/172.17.0.4:7687 - R:/25.91.226.19:42626] readAddress(..) failed: Connection timed out  
io.netty.channel.unix.Errors$NativeIoException: readAddress(..) failed: Connection timed out  
2024-09-02 19:19:38.784+0000 ERROR [o.n.b.t.p.HouseKeeper] Fatal error occurred when handling a client connection: [id: 0x4eba9080, L:/172.17.0.4:7687 - R:/25.91.226.21:36150] readAddress(..) failed: Connection timed out  
io.netty.channel.unix.Errors$NativeIoException: readAddress(..) failed: Connection timed out  
2024-09-02 19:19:38.784+0000 ERROR [o.n.b.t.p.HouseKeeper] Fatal error occurred when handling a client connection: [id: 0xbdff3583, L:/172.17.0.4:7687 - R:/25.91.226.21:55104] readAddress(..) failed: Connection timed out  
io.netty.channel.unix.Errors$NativeIoException: readAddress(..) failed: Connection timed out  

```

The queries that might time out are pure read operations, with no writes involved. Here's an example of a query:

```auto
session.readTransaction(tx -> {  
    Result result = tx.run(p_str);  
    while (result.hasNext()) {  
        Record record = result.next();  
        nodes.add(record.asMap().get("n.name").toString());  
    }  
    return nodes;  
}, config);  

```

Do you know what might be happening? Do you have any suggestions on how to avoid or improve this random query timeout issue?

Thank you in advance for your assistance.

Kenny
