Performance Mode โ Speed Up Your API
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โ
-
Request Arrives ๐ฅ
- API checks if Performance Mode is enabled (
PERFORMANCE_MODE=true
) - Looks for cached data in Redis
- API checks if Performance Mode is enabled (
-
Cache Check ๐
- If data exists in cache โ returns it immediately
- If not โ queries the database
-
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 ๐โ
-
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
-
Current Implementation ๐ฏ
- Only implemented for
checkVersion
endpoint - Perfect for high-frequency update checks
- More endpoints might be added in the future
- Only implemented for
-
When to Use โก
- High-traffic environments
- Systems with frequent update checks
- Scenarios where response time is critical
Best Practices ๐กโ
-
Enable in Production ๐
- Always use Performance Mode in production
- Especially if you expect high traffic
-
Monitor Performance ๐
- Keep an eye on response times
- Watch Redis memory usage
- Track database load
-
Regular Updates ๐
- Cache is automatically managed
- No manual intervention needed
- Just focus on your app!
How to try faynoSync?โ
-
Follow the Getting Started guide:
๐ https://ku9nov.github.io/faynoSync-site/docs/category/getting-started -
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 -
Upload at least two versions of your application.
-
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 ๐