

# Manage costs and usage
<a name="routes-whats-next"></a>

As you continue learning about Amazon Location routes, it's important to understand how to manage service capacity, ensure you follow usage limits, and get the best results through quota and API optimizations. By applying best practices for performance and accuracy, you can tailor your application to handle place-related queries efficiently and maximize your API requests.

**Topics**
+ [Best Practices](routes-best-practices.md)
+ [Routes pricing](routes-pricing.md)
+ [Routes Quota and Usage](routes-quota-usage.md)

# Best Practices
<a name="routes-best-practices"></a>

This section covers best practices for using compression and choosing between Simple (GeoJSON) and FlexiblePolyline formats when interacting with the API, providing guidance on optimizing performance, bandwidth, and data handling.

## Compression
<a name="compression"></a>

To enhance the performance and efficiency of your applications when interacting with our API, it is recommended to enable compression for responses, especially when dealing with large text-based payloads. You can activate compression by including the `Accept-Encoding` header in your API requests, specifying your preferred compression method. We support `gzip` and `deflate` for their compression capabilities, with `gzip` typically offering better compression ratios.

### When to Enable Compression
<a name="when-to-enable-compression"></a>

**Large responses**  
Enable compression for large text-based responses to reduce bandwidth usage and improve load times.

**Network constraints**  
If your application operates over limited bandwidth or high-latency networks, compression can enhance data transfer efficiency.

### How to Use Compression Effectively
<a name="how-to-use-compression-effectively"></a>

**Set the Accept-Encoding header**  
Include `Accept-Encoding: gzip, deflate` in your HTTP requests to inform our API that you support these compression methods. The method to enable and handle compression varies by [AWS SDK](https://docs.aws.amazon.com/sdkref/latest/guide/overview.html) and programming language. For example, the [AWS SDK for Java v1](https://docs.aws.amazon.com/AWSJavaSDK/latest/javadoc/com/amazonaws/ClientConfiguration.html#withGzip-boolean-) uses the `withGzip` method in the `ClientConfiguration` class to enable gzip, while the AWS SDK for Go requires adding specific middleware for compression handling. For other SDKs, please refer to the [AWS SDK Reference Guide](https://docs.aws.amazon.com/sdkref/latest/guide/overview.html) for detailed instructions.

**Handle decompression properly**  
Ensure your client application can correctly decompress the responses based on the `Content-Encoding` header returned by our API.

**Test and monitor**  
Regularly evaluate the impact of compression on your application's performance, balancing the benefits of reduced payload sizes against any additional CPU overhead from decompression processes.

## Polyline
<a name="polyline"></a>

Best practices for choosing between Simple (GeoJSON) and FlexiblePolyline formats when interacting with our API, to optimize both performance and usability of your geospatial data.

### Use Simple (GeoJSON) Format
<a name="use-simple-format"></a>

**Readability and Standardization**  
Use when you require a widely recognized and human-readable format for ease of debugging and interoperability with various geospatial tools.

**Precision**  
Choose Simple format when your application needs high precision for coordinates, as GeoJSON maintains full decimal precision without loss.

**Smaller datasets**  
Simple format is ideal when working with smaller sets of coordinate data where the size reduction benefits of compression are minimal.

### Use FlexiblePolyline Format
<a name="use-flexiblepolyline-format"></a>

**Data size reduction**  
FlexiblePolyline is ideal when you need to minimize the amount of data transmitted, especially for large lists of coordinates, by leveraging lossy compression techniques.

**URL safety**  
FlexiblePolyline provides a compact, URL-safe string that can be used directly in query parameters without additional encoding.

**Performance optimization**  
FlexiblePolyline helps reduce the payload size, leading to faster data transfer and lower bandwidth usage, making it crucial for high-performance applications or those operating over constrained networks.

# Routes pricing
<a name="routes-pricing"></a>

Please see below for pricing buckets for each API:

## Calculate Routes
<a name="calculate-routes-price"></a>

This price is based on the number of API requests. `CalculateRoutes` has three pricing buckets: Core, Advanced, and Premium.

**Core**  
 This pricing bucket supports the travel modes `Car`, `Truck`, and `Pedestrian`, without toll cost calculation. 

**Advanced**  
 This pricing bucket supports alternative travel modes such as `Scooter`, without toll cost calculation.   
 For [GrabMaps](https://docs.aws.amazon.com/location/latest/developerguide/GrabMaps.html) customers in `ap-southeast-1` and `ap-southeast-5`, the `Scooter` travel mode is part of the Core pricing bucket. 

**Premium**  
 This pricing bucket supports toll cost calculation. You will be charged at Premium price when you request toll cost calculation by setting the request parameters `LegAdditionalFeatures["Tolls"]` or `SpanAdditionalFeatures["TollSystems"]`, regardless of travel mode. 

## Calculate Route Matrix
<a name="calculate-route-matri-price"></a>

This price is based on the number of routes calculated. The number of routes calculated in each request is equal to the number of origins multiplied by the number of destinations, `Number of Routes = Number of origins x Number of Destinations`. For example, when using a matrix size of 300 origins by 100 destinations, the total number of routes calculated is 30,000 (300 x 100 = 30,000).

**Note**  
Route calculations are billed for each origin and destination pair. If you use a large matrix of origins and destinations, your costs will increase accordingly.

`CalculateRouteMatrix` has 2 pricing buckets: Core and Advanced.

**Core**  
 This pricing bucket supports the travel modes `Car`, `Truck`, and `Pedestrian`. 

**Advanced**  
This pricing bucket supports alternative travel modes such as `Scooter`.  
 For [GrabMaps](https://docs.aws.amazon.com/location/latest/developerguide/GrabMaps.html) customers in `ap-southeast-1` and `ap-southeast-5`, the `Scooter` travel mode is part of the Core pricing bucket. 

## Optimize Waypoint
<a name="optimize-waypoint-price"></a>

This price is based on the number of API requests. `OptimizeWaypoint` has 2 pricing buckets: Advanced and Premium.

**Advanced**  
 This pricing bucket supports up to 30 waypoints in a single request; travel modes for Car, Truck and Pedestrian, with the bounding box of the input points within 200km, and with no optional parameters such as `Avoid`, `Clustering`, `Driver`, `Exclude.Countries`, `TravelModeOptions.Truck.HazardousCargos`, `TravelModeOptions.Truck.TunnelRestrictionCode`, and no additional waypoints or destination constraints such as `AccessHours`, `AppointmentTime`, `Before`, `Heading`, `ServiceDuration`, `SideOfStreet`.  
Automatic clustering could occur when waypoints are in close proximity, but it is still considered as advanced pricing bucket.

**Premium**  
 This pricing bucket supports up to 50 waypoints in a single request; with no restrictions on travel modes; bounding box of the input points within 500km; and with optional parameters such as `Avoid`, `Clustering`, `Driver`, `Exclude.Countries`, `TravelModeOptions.Truck.HazardousCargos`, `TravelModeOptions.Truck.TunnelRestrictionCode`. In addition, this pricing bucket supports optional waypoint and destination constraints , such as `AccessHours`, `AppointmentTime`, `Before`, `Heading`, `ServiceDuration`, `SideOfStreet`.   
A single request can only support up to 20 waypoints if any of the optional waypoint and destination constraints is applied.

## Snap-to-road
<a name="snap-to-road-price"></a>

This price is based on the number of API requests. `SnaptoRoad` has 2 pricing buckets: Advanced and Premium.

**Advanced**  
This pricing bucket supports travel modes Car, Truck and Pedestrian, with a `TracePoints` count up to 200 and with a maximum airline distance between `TracePoints` of 100 kilometers.

**Premium**  
This pricing bucket has no restrictions on travel modes, up to 5,000 `TracePoints` points.

## Calculate Isoline
<a name="calculate-isoline-price"></a>

This price is based on the number of Isolines calculated in the response. `CalculateIsolines` has 2 pricing buckets: Advanced and Premium.

**Advanced**  
This pricing bucket supports travel modes Car, Truck and Pedestrian, with `Thresholds.Time` values up to 60 minutes or `Thresholds.Distance` values up to 100 kilometers.

**Premium**  
This pricing bucket has no restrictions on travel modes, with `Thresholds.Time` values up to 180 minutes or `Thresholds.Distance` values up to 300KM.

# Routes Quota and Usage
<a name="routes-quota-usage"></a>

## Service Quota
<a name="service-quota"></a>

Amazon Location Service APIs have default quotas. You can increase quotas using the [service quota console](https://console.aws.amazon.com/servicequotas/home#!/services/geo/quotas). For limits exceeding 2x the default, request via the self-service console or contact support.


**Service Quota Limits**  

| API Name | Default | Max Adjustable Limit | More than Adjustable Max Limit | 
| --- | --- | --- | --- | 
| [Calculate routes](calculate-routes.md) | 20 | 40 | Request on [service quota console](https://console.aws.amazon.com/servicequotas/home#!/services/geo/quotas) or contact support team | 
| [Calculate isolines](calculate-isolines.md) | 20 | 40 | Request on [service quota console](https://console.aws.amazon.com/servicequotas/home#!/services/geo/quotas) or contact support team | 
| [Snap to Roads](snap-to-roads.md) | 20 | 40 | Request on [service quota console](https://console.aws.amazon.com/servicequotas/home#!/services/geo/quotas) or contact support team | 
| [Calculate route matrix](calculate-route-matrix.md) | 5 | 10 | Request on [service quota console](https://console.aws.amazon.com/servicequotas/home#!/services/geo/quotas) or contact support team | 
| [Optimize waypoints](actions-optimize-waypoints.md) | 5 | 10 | Request on [service quota console](https://console.aws.amazon.com/servicequotas/home#!/services/geo/quotas) or contact support team | 

## Other Usage Limits
<a name="other-usage-limits"></a>

In addition to service quotas, the following API usage limits apply:


**Other Usage Limits**  

| API Name | Limit | Value | 
| --- | --- | --- | 
| [Snap to Roads](snap-to-roads.md) | Sum of Geodesic distance between all TracePoints | 500KM | 
| [Optimize waypoints](actions-optimize-waypoints.md) | Sum of Geodesic distance between the Origin, Waypoints in the provided ordering, and Destination | 100KM | 
| [Optimize waypoints](actions-optimize-waypoints.md) | Perimeter of the bounding box surrounding the Origin, Waypoints, and Destination | 500KM | 
| [Calculate route matrix](calculate-route-matrix.md) | Max Distance between Origins and Destinations for Unbounded routing (If Avoid or TravelModeOptions.Truck is used) | 60KM | 
| [Calculate route matrix](calculate-route-matrix.md) | Max Distance between Origins and Destinations for Unbounded routing | 10000KM | 
| [Calculate routes](calculate-routes.md) | Response payload size after compression | 6MB | 
| [Calculate route matrix](calculate-route-matrix.md) | Response payload size after compression | 6MB | 
| [Calculate isolines](calculate-isolines.md) | Response payload size after compression | 6MB | 
| [Optimize waypoints](actions-optimize-waypoints.md) | Response payload size after compression | 6MB | 
| [Snap to Roads](snap-to-roads.md) | Response payload size after compression | 6MB | 

## Next Steps
<a name="next-steps"></a>

Please check the following for further details:
+ [Attribution](https://docs.aws.amazon.com/location/latest/developerguide/data-attribution.html): Information on data attribution requirements for Amazon Location Service.
+ [SLA](https://aws.amazon.com/location/sla/): The service level agreement for Amazon Location Service, including uptime commitments and response times.
+ [Service Terms](https://aws.amazon.com/service-terms/): Terms governing the use of Amazon Location Service, including restrictions and limitations.