Sync vs Async
Understand the differences between synchronous and asynchronous PDF generation
Vortex PDF offers two distinct methods for generating PDFs: synchronous and asynchronous processing. Each approach has specific use cases and advantages depending on your application requirements.
Synchronous processing
With synchronous processing, your API request waits for the PDF generation to complete, and the rendered PDF is returned directly in the response.
Endpoint: POST /api/v1/renderers/pdf
🔗 API reference
When to use synchronous processing
- Immediate PDF delivery - When you need to return the PDF directly to users
- Simple documents - For generating relatively small or simple PDFs (fewer than 10 pages)
- Interactive applications - When users are actively waiting for the document
- Testing and development - For quicker iteration during development
How it works
- Your application makes a request to the synchronous endpoint
- Vortex PDF renders the document while the connection remains open
- Once complete, the PDF binary (or base64-encoded string) is returned in the response
- Your application can immediately use or serve the PDF
Asynchronous processing
With asynchronous processing, your request is queued for background processing. The API responds immediately with a confirmation, and the generated PDF is stored in your specified cloud storage location.
Endpoint: POST /api/v1/renderers/pdf/async
🔗 API reference
When to use asynchronous processing
- Large documents - For generating complex or lengthy PDFs (10+ pages)
- Batch processing - When generating multiple PDFs without blocking your application
- Background jobs - For non-interactive PDF generation tasks
- Scheduled reports - For recurring document generation that doesn’t require immediate access
- High-volume processing - When handling peaks in PDF generation demand
How it works
- Your application makes a request to the asynchronous endpoint
- Vortex PDF immediately returns a confirmation response
- The rendering job is processed in the background
- Upon completion, the PDF is stored in your specified cloud storage location
- Optionally, a webhook notification is sent to your callback URL
- In case of transient failures, the system will automatically retry the rendering process up to 5 times before reporting a failure
Required configuration differences
While most rendering options are identical between the two methods, asynchronous processing has some configuration differences:
Configuration | Synchronous | Asynchronous |
---|---|---|
output_encoding | Required (binary or base64) | Not applicable |
destination | Not applicable | Optional (cloud storage details) |
callback | Not applicable | Optional (webhook URL) |
Before using custom cloud destinations, you must configure proper authorization settings. See Cloud destination for detailed setup instructions.
Default storage for async processing
If you don’t specify a destination
parameter for asynchronous processing, Vortex PDF will automatically store your generated PDF in our public cloud storage:
- Bucket:
public.vortexpdf.com
- Region: Multiple regions in the United States
- Lifecycle: Files are automatically deleted after 14 days
- Access: Public URL provided in callback response
This default storage option is perfect for testing, development, or temporary document sharing scenarios.
Response differences
The synchronous endpoint returns the actual PDF document in the response body, while the asynchronous endpoint returns a confirmation that the job has been accepted.
Synchronous response
Asynchronous response
When using the default storage (no destination specified), the callback response payload will match Google Cloud Storage’s response format.
Example callback payloads
When using asynchronous processing, you’ll receive a callback with details about the stored PDF. The payload structure varies depending on the storage provider.
Google Cloud Storage
When using Google Cloud Storage as the destination provider:
AWS S3 storage
When using AWS S3 as the destination provider:
Error callback payloads
When async PDF generation fails, you’ll receive error details in the callback payload:
Google Cloud Storage errors
AWS S3 errors
Performance considerations
- Timeouts - Synchronous requests may timeout for complex documents, especially with many images or complex layouts
- Connection stability - Synchronous requests require maintaining an open connection throughout the rendering process
- Scaling - Asynchronous processing handles traffic spikes more gracefully by queuing requests
- Resource utilization - Asynchronous processing distributes your PDF generation load more evenly
- Automatic retries - Asynchronous processing includes automatic retry logic for transient failures, increasing reliability for complex documents
Example: Synchronous rendering
Example: Asynchronous rendering
With custom destination
Best practices
- Use synchronous processing for small documents and interactive user experiences
- Switch to asynchronous processing for documents over 10 pages or with complex layouts
- Use the default storage option for rapid development and testing
- Configure your own cloud storage destination when:
- Running production workloads
- Handling sensitive or regulated information
- Needing to comply with data residency requirements (GDPR, HIPAA, etc.)
- Requiring specific geographic storage locations
- Implementing custom retention policies beyond 14 days
- Implement proper error handling for both methods
- Set appropriate timeouts for synchronous requests
- Use webhook callbacks to trigger downstream processes when using asynchronous rendering