Skip to main content

Performance Utilities

Edge-Utils provides comprehensive performance monitoring and optimization tools specifically designed for edge computing environments.

Features

  • Cold Start Detection: Monitor and optimize cold start performance
  • Streaming Responses: Efficient streaming for large responses
  • Performance Metrics: Real-time performance monitoring
  • Compression: Automatic response compression
  • Resource Monitoring: Memory and CPU usage tracking

Cold Start Detection

Monitor and optimize cold start performance in serverless environments.

Advanced Cold Start Handling

Streaming Responses

Handle large responses efficiently with streaming.

Advanced Streaming

Performance Monitoring

Monitor application performance in real-time.

Custom Metrics

Compression

Automatic response compression for better performance.

Advanced Compression

Resource Monitoring

Monitor memory and CPU usage in edge environments.

Performance Optimization Tips

1. Connection Pooling

2. Caching Strategy

3. Lazy Loading

Platform-Specific Optimizations

Cloudflare Workers

Vercel Edge Functions

Best Practices

1. Monitor Key Metrics

2. Implement Circuit Breakers

3. Use Appropriate Timeouts

API Reference

PerformanceMonitor

  • start(label) - Start timing a operation
  • end(label) - End timing an operation
  • getDuration(label) - Get duration of an operation
  • getMemoryUsage() - Get current memory usage
  • getCpuUsage() - Get current CPU usage

ColdStartDetector

  • isColdStart() - Check if current execution is a cold start
  • getColdStartCount() - Get number of cold starts
  • reset() - Reset cold start counter

StreamingResponse

  • write(data) - Write data to stream
  • end() - End the stream
  • getReader() - Get stream reader

CompressionManager

  • compress(response, options) - Compress a response
  • shouldCompress(response) - Check if response should be compressed
  • getSupportedAlgorithms() - Get supported compression algorithms