Skip to main content

One post tagged with "Performance"

Performance documentation for FaynoSync

View All Tags

Performance Mode โ€” Speed Up Your API

ยท 3 min read

Is your faynoSync instance handling thousands of update checks per minute? Worried about database load? Meet Performance Mode โ€” your API's new best friend for handling high traffic efficiently!


What is Performance Mode? ๐Ÿค”โ€‹

Performance Mode is a smart caching system that:

  • ๐Ÿš€ Reduces response times
  • ๐Ÿ“‰ Lowers database load
  • ๐Ÿ’พ Optimizes resource usage

It works by caching frequently requested data in Redis, making your API responses lightning-fast!


How It Works ๐Ÿ› ๏ธโ€‹

The Magic Behind the Scenesโ€‹

  1. Request Arrives ๐Ÿ“ฅ

    • API checks if Performance Mode is enabled (PERFORMANCE_MODE=true)
    • Looks for cached data in Redis
  2. Cache Check ๐Ÿ”

    • If data exists in cache โ†’ returns it immediately
    • If not โ†’ queries the database
  3. Cache Update ๐Ÿ’พ

    • New data is stored in Redis
    • Ready for next request

What Gets Cached?โ€‹

Currently, Performance Mode is implemented for the checkVersion endpoint, which is one of the most frequently called endpoints in the system.


Why Do We Need It? ๐ŸŽฏโ€‹

1. Database Load Reductionโ€‹

  • ๐Ÿ“Š Fewer queries to MongoDB
  • ๐Ÿ’ช Less strain on your database
  • ๐ŸŽฏ Better resource utilization

2. Faster Response Timesโ€‹

  • โšก Cached responses are returned instantly
  • ๐ŸŽ๏ธ No need to wait for database queries
  • ๐ŸŽฎ Perfect for high-traffic scenarios

3. Resource Optimizationโ€‹

  • ๐ŸŒฑ Lower CPU usage
  • ๐Ÿ’ง Reduced memory consumption
  • ๐Ÿ“ˆ Better scalability

How to Enable It? ๐Ÿ”Œโ€‹

Just add this to your .env file:

PERFORMANCE_MODE=true

That's it! Your API will automatically start using Redis for caching.


Testing Performance ๐Ÿงชโ€‹

Want to see the difference? Try this test script:

start_time=$(date +%s); 
for i in {1..1000}; do
response=$(curl -s -w "Connect Time: %{time_connect}s, Start Transfer Time: %{time_starttransfer}s, Total Time: %{time_total}s\n" -o /dev/stdout --location 'http://localhost:9000/checkVersion?app_name=myapp&version=0.0.3&channel=nightly&platform=null&arch=null');
echo "$response";
done;
end_time=$(date +%s);
total_time=$((end_time - start_time));
echo "Total execution time: $total_time seconds"

Compare the results with and without Performance Mode enabled!


Important Notes ๐Ÿ“โ€‹

  1. Cache Invalidation ๐Ÿ”„

    • Cache is automatically cleared when you publish a new version
    • New data is cached on the next request
    • Ensures users always get the latest information
  2. Current Implementation ๐ŸŽฏ

    • Only implemented for checkVersion endpoint
    • Perfect for high-frequency update checks
    • More endpoints might be added in the future
  3. When to Use โšก

    • High-traffic environments
    • Systems with frequent update checks
    • Scenarios where response time is critical

Best Practices ๐Ÿ’กโ€‹

  1. Enable in Production ๐Ÿš€

    • Always use Performance Mode in production
    • Especially if you expect high traffic
  2. Monitor Performance ๐Ÿ“Š

    • Keep an eye on response times
    • Watch Redis memory usage
    • Track database load
  3. Regular Updates ๐Ÿ”„

    • Cache is automatically managed
    • No manual intervention needed
    • Just focus on your app!

How to try faynoSync?โ€‹

  1. Follow the Getting Started guide:
    ๐Ÿ‘‰ https://ku9nov.github.io/faynoSync-site/docs/category/getting-started

  2. Create your app using the REST API or web dashboard:
    ๐Ÿ“ฆ API Docs: https://ku9nov.github.io/faynoSync-site/docs/api
    ๐Ÿ–ฅ๏ธ Dashboard UI: https://github.com/ku9nov/faynoSync-dashboard

  3. Upload at least two versions of your application.

  4. Check for updates with this simple request:
    ๐Ÿ“ก /info/latest


If you find this project helpful, please consider subscribing, leaving a comment, or giving it a star, create Issue or feature request on GitHub.
Your support keeps the project alive and growing ๐Ÿ’š