[JAVA-864] Lookups in replica set take 20% of CPU time Created: 05/Jul/13 Updated: 11/Sep/19 Resolved: 18/Jul/13 |
|
| Status: | Closed |
| Project: | Java Driver |
| Component/s: | Connection Management |
| Affects Version/s: | 2.11.2 |
| Fix Version/s: | None |
| Type: | Task | Priority: | Critical - P2 |
| Reporter: | Nic Cottrell (Personal) | Assignee: | Unassigned |
| Resolution: | Cannot Reproduce | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Environment: |
Java 6 |
||
| Attachments: |
|
| Description |
|
We have a replica set with 2 nodes and a arbiter. We originally had the java driver configured using the hostnames and about 40% of the CPU time reported by JProfiler was getByName. I've now configured so that it's the IP address specified in the ServerAddress()... but it's still 20% via ServerAddress.updateInetAddress. Is it perhaps because the config of the replica set itself it still specified with hostnames not IP addresses? I saw a mention of configuring a cache timeout for mapping, but I couldn't find it in the docs. Also, I saw that in the 3.x Java driver that caching is going to be removed completely. What am I missing? How can this take so much CPU? |
| Comments |
| Comment by Jeffrey Yemin [ 18/Jul/13 ] | ||||||||
|
Closing this now but please open a new issue if you want to request a feature enhancement. | ||||||||
| Comment by Jeffrey Yemin [ 18/Jul/13 ] | ||||||||
|
I don't think the driver should be getting involved. There are already JVM settings available that are under the user's control that can influence the caching behavior (see http://stackoverflow.com/questions/12099526/setting-java-dns-cache-ttl), so anything that the driver does just adds another layer, which is something that has confused many of our users. | ||||||||
| Comment by Nic Cottrell (Personal) [ 18/Jul/13 ] | ||||||||
|
Looks like I have caching of one minute (this applies to both hostnames) and decent results after the first: {{ Is it worth increasing the caching? Will risk making it hard to move servers around if a hosting environment goes down.... | ||||||||
| Comment by Jeffrey Yemin [ 08/Jul/13 ] | ||||||||
|
Try running a program like this:
substituting your server's hostname in the call to InetAddress.getByName. When I run this I get very reasonable response times of under 10ms for the first call and under 1 ms for subsequent calls, showing the effect of the JVMs built-in DNS cache. |