Blog

5 Ways to Optimize API Performance with DreamFactory

Written by Kevin McGahey | April 4, 2025

API performance is critical for user satisfaction and operational efficiency. DreamFactory offers powerful tools to address common API challenges like slow response times, excessive data transfer, and server overload. Here’s how you can optimize API performance effectively:

  1. Enable API Caching: Use Redis, Memcached, or local caching to reduce database load and speed up API responses.
  2. Set Traffic Controls: Implement rate limits and dynamic traffic management to prevent overload and ensure stability.
  3. Reduce Response Sizes: Compress responses, filter data, and use pagination to minimize bandwidth usage.
  4. Tune Database Performance: Optimize queries, use indexes, and leverage stored procedures for faster data retrieval.
  5. Scale APIs: Use load balancers, horizontal scaling, and cloud deployments to handle growing traffic demands.

Quick Overview of Key Strategies

 

Strategy

Benefit

Example

Caching

Faster API responses

Redis or Memcached setup

Traffic Control

Prevents system overload

Rate limiting by user

Response Optimization

Smaller payloads

Gzip compression

Database Tuning

Faster query execution

Add indexes to key columns

Scaling

Handles high traffic

Load balancer configuration

DreamFactory simplifies these tasks with automated tools, built-in security, and flexible deployment options, ensuring your APIs are efficient and scalable.

Top 7 Ways to 10x Your API Performance

 

 

API Caching Methods

DreamFactory offers support for local, Redis, and Memcached caching options to improve API performance [3].

Setting Up Server-Side Caching

To enable server-side caching, you'll need to choose a backend and configure the cache settings.

  • Pick a Cache Backend
    • Local cache: Ideal for simple or single-server setups.
    • Redis: Great for structured and persistent caching needs.
    • Memcached: Best suited for distributed caching scenarios.

Managing Cache Duration

Once your cache is set up, assign appropriate TTL (Time-To-Live) values to balance performance with data freshness [4].

Shorter TTLs: Use for frequently changing data:

  • Sessions: 15–30 minutes
  • Real-time metrics: 1–5 minutes
  • API tokens: 60 minutes

Longer TTLs: Use for more static data:

  • Configuration: 24 hours
  • Product catalogs: 12 hours
  • Documentation: 48 hours

Using Redis for Caching

Redis is a powerful option for high-speed and low-latency caching [1]. To integrate Redis, configure the following parameters in DreamFactory:


To ensure optimal performance, monitor these Redis metrics regularly:

  • Cache hit rate: Indicates how often requested data is found in the cache.
  • Memory usage: Helps manage resource allocation.
  • Eviction rates: Shows how often items are removed from the cache due to space limits.
  • Connection status: Ensures Redis is running smoothly.

Traffic Control and Rate Limits

DreamFactory includes traffic control measures to keep your APIs running smoothly and prevent system overload. With built-in rate limiting, you can manage API access across different levels - whether it's for the entire instance, specific users, particular services, or even individual endpoints. This ensures fair usage while protecting your system from excessive demand.

Setting API Rate Limits

DreamFactory uses a structured system to manage API access, which you can configure through the Admin App or the api/v2/system/limit endpoint. Key parameters include:

  • Type: Defines the scope (e.g., instance, instance.user, instance.user.service).
  • Rate: Specifies the number of allowed hits within the defined period.
  • Period: Determines the time frame for resetting the limit.
  • Target Identifiers: Optional fields like user_id or service_id for more granular control.

Here’s an example of a JSON configuration:

Dynamic Traffic Management

DreamFactory also supports real-time traffic management to handle varying demand levels. Here are some key strategies:

  • Horizontal Scaling: Add multiple DreamFactory instances behind a load balancer to distribute incoming API requests efficiently.
  • Read Replicas: Use read replicas to handle database read operations, reducing the strain on your primary instance during traffic spikes.
  • Adaptive Throttling: The system dynamically adjusts request processing based on server load and predefined thresholds. Features like caching, SQL function integration, and multi-tier architecture enhance this process.

Usage Tracking and Limits

Keep an eye on API usage with real-time stats and flexible limit configurations. Short- and long-term limits can be set, and for deeper insights, you can integrate with Elastic Stack analytics. To view active limit counts, remaining quota, or reset timings, use the api/v2/system/limit_cache endpoint.

DreamFactory’s cache-based system enforces limits automatically, ensuring your APIs remain stable and responsive even during high-traffic periods.

Response Size Optimization

Reducing API response sizes is a smart way to improve performance and cut down on bandwidth usage. While caching and traffic controls are essential, trimming response sizes takes efficiency to the next level.

Setting Up Response Compression

Compressing responses can significantly reduce the amount of data transferred. Here's how to set it up for Nginx and Apache:

For Nginx, include these directives in your VirtualHost configuration:


For Apache, enable mod_deflate and update your VirtualHost settings as follows:


These configurations ensure responses are compressed when clients include the Accept-Encoding header.

Filtering and Pagination for Large Datasets

DreamFactory makes it easier to manage large datasets by offering tools for filtering and pagination.

  • Filtering Specific Data: Use filters to request only the data you need. For example:

  • Pagination Options: DreamFactory supports two types of pagination:
    • Offset-based: Specify the number of records and starting point.

    • Cursor-based: Ideal for large datasets, this method uses unique identifiers to navigate between pages.
    • Server-side Filtering: Limit data access based on user roles. For instance:

These tools ensure efficient data handling and help tailor responses to specific needs.

Database Performance Tuning

API response times heavily depend on database performance. DreamFactory enhances API efficiency by optimizing database operations. These methods complement earlier strategies to ensure faster and scalable APIs.

Query Builder Best Practices

DreamFactory's Query Builder simplifies and speeds up database queries. Here's how it works:

  • Filtering
    Retrieve specific records with filtering:
    GET /api/v2/db/_table/contact?filter=(first_name = 'Jon') and (last_name = 'Yang')

For partial matches:
GET /api/v2/db/_table/contact?filter=last_name like 'Y%'


  • Parameter Optimization
    • Select only the fields you need instead of using SELECT *.
    • Use WHERE clauses to narrow down results.
    • Ensure proper JOIN conditions for efficient queries.

Database Index Setup

Indexes play a key role in speeding up query performance. Focus on indexing columns that are:

  • Frequently used in filters
  • Part of JOIN conditions
  • Used in ORDER BY clauses
  • Foreign keys

For example, to improve performance in a customer orders table:

Using Stored Procedures

Stored procedures handle complex operations directly on the database server, improving efficiency. DreamFactory allows you to call stored procedures using GET and POST methods.

Benefits of stored procedures include:

  • Faster execution since they are precompiled
  • Reduced network load
  • Better security
  • Easier maintenance

Example of calling a stored procedure:


Query Method Comparison

Here's a quick look at when to use each query method:

Method

Best Use Case

Performance Impact

Direct Query

Simple data retrieval

Basic operations

Query Builder

Advanced filtering

Handles dynamic queries

Stored Procedures

Complex operations

Ideal for high-volume tasks

 

API Scaling with DreamFactory

DreamFactory is designed to handle growing API demands through both vertical and horizontal scaling.

Load Balancer Setup

DreamFactory integrates seamlessly with load balancers to spread API traffic across multiple servers. Its stateless architecture, powered by JWT (JSON Web Token) authentication, ensures any server can process requests without needing to maintain user sessions.

Key configurations for load balancers include:

  • Health Monitoring: Set up health checks to automatically remove unresponsive servers.
  • Algorithm Selection: Choose scheduling algorithms tailored to your workload patterns.
  • Cluster Setup: Use redundant load balancers to eliminate single points of failure.

While load balancing is crucial, adding server capacity also plays a major role in scaling effectively.

Adding Server Capacity

Here are the main approaches to scaling:

Scaling Method

Best For

Implementation

Vertical Scaling

Immediate performance needs

Add more CPU or RAM to existing servers

Horizontal Scaling

Supporting long-term growth

Deploy additional server instances

Hybrid Approach

Managing dynamic workloads

Combine both vertical and horizontal scaling

To optimize performance, consider using NGINX to handle more requests while minimizing memory usage [5].

Cloud Deployment Options

DreamFactory can be deployed on bare metal, virtual machines, or container platforms. While it doesn’t offer its own cloud service [7], you can easily deploy it on:

  • Bare metal servers
  • Virtual machines
  • Container platforms like Docker or Kubernetes

This flexibility allows organizations to save an average of $45,719 per API by streamlining deployment and management [2].

Key configuration requirements include:

  • Sharing access to the same file storage system across all web servers.
  • Properly configuring JWT for secure authentication.
  • Setting up monitoring and logging with tools like the ELK stack.

For larger enterprise setups, a hybrid deployment model - combining on-premises infrastructure with cloud scalability - offers a balance of security and flexibility. This approach ensures you can scale resources as needed while maintaining control over sensitive data [6].

Conclusion

 

Summary of Methods

DreamFactory improves API performance through a combination of caching, traffic control, response optimization, database tuning, and scaling.

Optimization Strategy

Benefits

Implementation Impact

API Caching

Lowers database load and speeds up responses

Faster response times

Traffic Control

Prevents misuse and protects resources

Greater stability during heavy usage

Response Optimization

Reduces data transfer and processing overhead

Efficient data handling and smaller payloads

Database Performance

Improves query execution and data retrieval

Quicker, smoother database operations

API Scaling

Manages concurrent requests effectively

Handles high volumes of API calls

 

Long-term API Management

Short-term improvements are important, but maintaining API performance over time is just as critical. This requires consistent monitoring and proactive adjustments. DreamFactory's multi-tier architecture lays a solid groundwork for building secure, high-performing APIs. Its adaptable design also supports custom logic to address changing needs.

To keep your APIs running smoothly:

  • Track performance metrics regularly.
  • Adjust caching settings to match how often your data changes.
  • Review and update API rate limits as necessary.

DreamFactory combines automated API generation, robust security, and flexible deployment options to ensure continuous improvement. By applying these practices, your API infrastructure stays efficient and ready for future demands.