massalabs / massa

The Decentralized and Scaled Blockchain
https://massa.net
5.58k stars 717 forks source link

Tests for API flood resilience #4479

Closed Leo-Besancon closed 8 months ago

Leo-Besancon commented 9 months ago

Using the massa-test-framework, we can write functional tests that ensures:

Limits should be tested on a referance machine (e.g. k8s cluster).

aoudiamoncef commented 9 months ago
aoudiamoncef commented 8 months ago

@Leo-Besancon

Rethinking Massa Public API Load Testing Strategy

Introduction: The Massa Public API serves as a critical component in our system architecture, connecting various services and enabling seamless communication. Load testing plays a vital role in ensuring the API's robustness, scalability, and reliability. However, a recent evaluation prompts us to reconsider our approach to load testing, specifically focusing on the absence of rate limiting and the necessity of exposing the API to the internet via a reverse proxy.

1. Absence of Rate Limiting: One of the key aspects of load testing is understanding how the system performs under different levels of demand. Rate limiting, the ability to restrict the number of requests a client can make within a specific timeframe, is a fundamental mechanism to prevent abuse, manage server resources, and maintain a consistent quality of service. The Massa Public API currently lacks rate limiting, which raises questions about the accuracy and relevance of our load tests. Without this essential feature, load testing may not accurately simulate real-world scenarios where API usage needs to be controlled and managed.

2. Exposure via Reverse Proxy: Security is paramount when it comes to exposing APIs to the internet. Utilizing a reverse proxy adds an additional layer of security, protecting the API from direct exposure and potential security threats. It acts as a shield, filtering and processing requests before they reach the API server. Without a reverse proxy, the API is vulnerable to various attacks, potentially impacting its performance and stability. However, when load testing, the absence of this security layer might lead to skewed results, as the API is directly exposed, bypassing the protective measures a reverse proxy provides.

3. Reevaluating Load Testing Priorities: Given the absence of rate limiting and the need for a reverse proxy, it's crucial to reconsider our load testing priorities. While load testing remains essential, the focus should shift towards addressing these fundamental concerns first. Implementing rate limiting within the API ensures that load tests simulate realistic usage patterns. Additionally, deploying a reverse proxy enhances security, safeguarding the API from potential threats during testing and real-world usage.

Conclusion: In summary, the Massa Public API load testing strategy requires a revision. Addressing the absence of rate limiting and ensuring the API is exposed via a reverse proxy are fundamental steps before conducting meaningful load tests. By prioritizing these aspects, we not only enhance the accuracy of our tests but also fortify the API against potential security vulnerabilities, ensuring a robust and reliable system for our users.