Book Image

RESTful Java Patterns and Best Practices

By : Bhakti Mehta
Book Image

RESTful Java Patterns and Best Practices

By: Bhakti Mehta

Overview of this book

<p>The convergence of social networking, cloud computing, and the era of mobile applications has created a generation of emerging technologies that allow different networked devices to communicate with each other over the Internet with REST. REST has the benefits of being stateless; easing scalability, visibility, and reliability; and being platform and language agnostic.</p> <p>This book is a practical, hands-on guide that provides you with clear and pragmatic information to take advantage of the real power of RESTful services and gives you a good foundation for using them in your applications. By comparing APIs from platforms such as Facebook, Twitter, GitHub, and PayPal, the book teaches a range of exciting capabilities with RESTful services and explores the infinite possibilities by using the diverse building blocks and tips covered in various chapters.</p> <p>By the end of the book, you will be able to successfully use the concepts explained to design and implement applications based on best practices for RESTful services.</p>
Table of Contents (15 chapters)
RESTful Java Patterns and Best Practices
Credits
About the Author
Acknowledgments
About the Reviewers
www.PacktPub.com
Preface
Index

Rate-limiting patterns


Rate limiting involves restricting the number of requests that can be made by a client. A client can be identified based on the access token it uses for the request as covered in Chapter 3, Security and Traceability. Another way the client can be identified is the IP address of the client.

To prevent abuse of the server, APIs must enforce throttling or rate-limiting techniques. Based on the client, the rate-limiting application can decide whether to allow the request to go through or not.

The server can decide what the natural rate limit per client should be, say for example, 500 requests per hour. The client makes a request to the server via an API call. The server checks if the request count is within the limit. If the request count is within the limit, the request goes through and the count is increased for the client. If the client request count exceeds the limit, the server can throw a 429 error.

The server can optionally include a Retry-After header, which indicates...