Saltar al contenido

ProvisionedThroughputExceededException on deleteFaces

0

Hi in ap-southeast-1 I'm trying to call deleteFaces for 1000 faces 1 call in 2 seconds from NodeJS. After 3-th call I get ProvisionedThroughputExceededException exception. but I see that all regions supports 5 requests per second. Even more in documentation i found that i can delete 4096 faces per call. but unfortunately when I'm trying to delete 4096 at ones i get the same exception. could you suggest what i must do to solve the issue. below is the code:

this.deleteFacesFromCollection = async function ({ collectionName, faceIds }) { for (let i = 0; i < faceIds.length; i += 1000) { const chunk = faceIds.slice(i, i + 1000); try { await rekognition.deleteFaces({ FaceIds: chunk, CollectionId: collectionName }).promise(); logger.info( deleteFacesFromCollection: ${chunk.length} faces deleted from ${collectionName} , ); await util.sleep(2000); } catch (error) { if (error.name === 'ProvisionedThroughputExceededException') { await util.sleep(2000); try { await rekognition.deleteFaces({ FaceIds: chunk, CollectionId: collectionName }).promise(); logger.info( deleteFacesFromCollection: ${chunk.length} faces deleted from ${collectionName} , ); } catch (error1) { logger.warn( deleteFacesFromCollection failed to delete faces from collection ${collectionName}. ERROR: ${error1}, ); } } else { logger.warn( deleteFacesFromCollection failed to delete faces from collection ${collectionName}. ERROR: ${error}, ); } } } };

preguntada hace 5 meses71 visualizaciones
1 Respuesta
1

When you encounter a ProvisionedThroughputExceededException while using Amazon Rekognition's DeleteFaces operation, it means you've exceeded the throughput limits for your account in that region.

Looking at your code, I can see you're already implementing some best practices like chunking your requests (1000 faces per call) and adding sleep intervals between calls (2 seconds). However, you're still hitting throughput limits.

Here are some suggestions to solve this issue:

  1. Increase the sleep time: Try increasing your sleep interval between calls from 2 seconds to 5 or even 10 seconds to reduce your request rate further.

  2. Implement exponential backoff: Instead of a fixed sleep time, implement an exponential backoff strategy where you progressively increase the wait time between retries.

  3. Reduce batch size: Try reducing your batch size from 1000 faces to a smaller number, such as 500 or 250 faces per request.

  4. Contact Amazon Rekognition: The error message specifically mentions "If you want to increase this limit, contact Amazon Rekognition." You can request a service limit increase through AWS Support if you need higher throughput.

  5. Implement more robust error handling: Your current retry logic only attempts once after a throughput exception. Consider implementing multiple retries with increasing backoff periods.

While the documentation may indicate that you can delete up to 4096 faces per call and make 5 requests per second, these limits might vary based on your specific account settings, region, or other factors. The actual throughput you can achieve might be lower than the documented maximum.
Sources
DeleteFaces - Amazon Rekognition
Amazon Rekognition examples using SDK for .NET - AWS SDK Code Examples
Use DeleteFaces with an AWS SDK or CLI - Amazon Rekognition

respondido hace 5 meses

No has iniciado sesión. Iniciar sesión para publicar una respuesta.

Una buena respuesta responde claramente a la pregunta, proporciona comentarios constructivos y fomenta el crecimiento profesional en la persona que hace la pregunta.