Announcement Announcement Module
Collapse
No announcement yet.
LDAP Connections Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • LDAP Connections

    Hi All,
    I am using Spring LDAP to create/delete/query entries to Sun Directory Server LDAP. The API as such is very convenient. But of late I am observing some performance issues while creating / deleting bunch of users (say 100). The typical scenario is when I add 100 users, the first 20 users are added instantaneously (typically each taking aroung 100 - 200 msecs). But for the 21st entry it is taking 2 minutes for the creation/deletion. Then for the next 20 users it is instantaneous and again wait for the next creation/deletion. When I observer the LDAP logs, I observed that each creation/deletion is creating a seperate connection. Is there any way I can use a single connection to do all my create/delete operations rather than one connection for each create/delete. I tried extending the LDAPTemplate so that I open a context do all my operations and then close the context. But still it is opening a seperate connection for each operation. Any insight to where I am going wrong would be greatly appreciated.

    Thanks,
    Praveen

  • #2
    If your usePooling flag (in ContextSource) is set to true (which is the default setting), it really shouldn't form a new connection for each operation (even though the DirContext holding the connection is closed after each operation). This is however managed in the LDAP provider in Java and is pretty much out of our control.

    Setting the 'com.sun.jndi.ldap.connect.pool.debug' system property to true will enable you to more closely monitor the connection handling on the client side. There are several other pooling flags you can play around with, described here.

    The LdapTemplate class is not intended to be subclassed and I would advise against playing around with the DirContext management that way - it's pretty easy to lose a connection somewhere causing a leak.

    My guess is that the main performance problem is caused by the LDAP server rebuilding indexes. LDAP servers are typically not designed for performing massive amounts of updates; they are optimized for reading, which means that keeping indexes up to date will be expensive if lots of updates happen at the same time. This might be configurable on the server side and something you might want to look into.

    As a side topic, we are currently working on implementing client side transaction support in Spring LDAP. Using this transaction support will cause the same DirContext instance (effectively: the same connection) throughout the same transaction. This is implemented using a proxy on DirContext, intercepting the DirContext.close() method, letting the transaction manager actually close the context once the transaction is finished. This won't solve any performance problem caused by index rebuilding however.

    Comment


    • #3
      Thanks rasky. I was subclassing LDAPTemplate not as part of the app, I was developing. But rather as a test to see if using the same context (without closing) to do all the operations. I will try to monitor the client side connections closely according to suggestions you gave.

      Comment

      Working...
      X