Skip to content

Implement Connection Persistence and Asynchronous Support #1

@cferrys

Description

@cferrys

The current Perl client implementation relies on LWP::UserAgent in a strictly synchronous, blocking manner without explicit connection pooling. To align with hlquery's high-performance goals, the API should support persistent connections (HTTP Keep-Alive) and offer an asynchronous interface for modern Perl event loops.

Context

hlquery is a high-performance search engine where low latency is critical. The current Perl client (Hlquery::Request) establishes new TCP/TLS connections frequently, introducing significant overhead. Furthermore, in modern Perl environments like Mojolicious or AnyEvent, the blocking nature of the current client prevents concurrent operations, making it a bottleneck for high-throughput applications.

Proposed Implementation

  1. Connection Pooling: Integrate LWP::ConnCache into Hlquery::Request to enable reuse of TCP connections across requests, reducing handshake latency.
  2. Asynchronous Client: Introduce a non-blocking client variant (e.g., Hlquery::AsyncClient) utilizing Mojo::UserAgent or Promises to allow concurrent search operations.
  3. Lazy JSON Decoding: Implement support for streaming or lazy decoding of large search results to minimize memory pressure when handling massive datasets.

Impact

  • 30-50% Latency Reduction: Connection reuse avoids repeated TCP/TLS handshakes, which is critical for a high-performance search engine.
  • Improved Concurrency: Enables Perl-based services to handle hundreds of concurrent search queries without blocking the main event loop.
  • Better Resource Management: Reduced socket churn and memory footprint for large-scale indexing or search operations.

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions