Skip to content

Conversation

edospadoni
Copy link
Member

@edospadoni edospadoni commented Sep 25, 2025

Summary

Implements chunked loading for phonebook contacts to prevent memory exhaustion and timeouts with large contact lists.

Changes

  • Chunking: Process contacts in 8K chunks instead of loading all at once
  • Resource limits: Added 256M memory limit, 400MB usage cap, 45s timeout protection
  • Retry logic: Automatic retry (max 2) for failed chunk requests
  • If-Modified-Since fix: Fallback to $_SERVER['HTTP_IF_MODIFIED_SINCE'] when apache_request_headers() fails
  • Error handling: cURL error detection, JSON encoding validation, detailed logging
  • Memory optimization: Free memory after each chunk, optimized contact data structure

Why

Large phonebooks (1000s of contacts) caused timeouts and memory exhaustion. Chunked processing with retry and resource monitoring resolves these issues.

@edospadoni edospadoni changed the title fix: added chunk in contacts response fix: added chunks in contacts response Sep 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants