简体   繁体   中英

Increase in time with SpringLDAP and ModifyAttributes

I have noticed that when I do a call to modifyAttributes via SpringLDAP, the time that it takes to do this increases as the object in the LDAP grows. At first I thought that it was the LDAP that was causing this, but after having turned on Ldap auditing, I noticed that so was not the case.

When I have nothing in the ldap objects seeAlso attribute, adding something into it takes roughly 200ms (In Java, 3ms of this is measured on the ldap), however, when I have around 1000 items in the seeAlso attribute, I see a time of roughly 7 seconds (In Java) and less than one second in my ldap audit.

I can only assume that it is SpringLdap that adds this time for some reason. Is there anyway I can either investigate further to see where the true bottleneck is, or can I optimize SpringLdap in anyway as to avoid this?

DirContextOperations ctx = ldapTemplate.lookupContext(organizationalRole.getDn());    
ctx.addAttributeValue(LdapConstants.ATTR_SEEALSO, applicationRoleDN.toString());
ldapTemplate.modifyAttributes(ctx);

Turns out that there was code logging the responses we got back from the LDAP. As the objects grew, the time to log increased. Once this was removed, as was our problem.

As a secondary step, I also went through the code and ensured that we now do any lookup/search/searchForObject with an AttributesMapper, to ensure that we do not query the LDAP for the entire object always, but only for the attributes we are interested in.

I wonder if what you are seeing is SpringLDAP implementing some error checking.

Most directories (eDirectory, Active Directory, and probably OpenLDAP as well) do not allow you to add the same value twice to a multi-valued attribute.

That is, you cannot have an MV attr acmeMyList that has the value 1974 and then add a second value 1974 to it. That is an error case.

As the number of values grows, the cost to check this increases, which fits your model.

Often indexing the attributes makes a difference in performance. As it turns out, eDirectory will automagically add an index for you, if you have any attribute with more than 25 values on any object. This is because the cost of maintaining the index becomes less than the cost of adding values to the attribute.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM