Amplify-js: Limit of 50 subscriptions reached Datastore

Created on 2 Mar 2020  路  10Comments  路  Source: aws-amplify/amplify-js

Describe the bug
I'm using Amplify Datastore with more than 17 models. As a result, the graphql schema built by amplify contains more than 50 subscriptions which results in the lost of synchronization with the cloud and the warning: [WARN] 52:19.547 DataStore - Sync error subscription failed Connection failed: {"errors":{"errorType":"MaxSubscriptionsReachedError","message":"Max number of 50 subscriptions reached"}}.

As a workaround I have decided to set some of the subscriptions in the models to 'null' wich results in less than 50 subscriptions in the compiled graphql (and on the appsync console). The frontend seems fine as the models have subscriptions: null as a property in schema.js in the 'models' folder.

However, I still have the warning and the lost of synchronization in my frontend. The only way I have found to solve this, is to manually change the 'schema.js' file in the 'models' folder and to set the property 'syncable' of the concerned models to false.

Amplify CLI Version
4.13.4

To Reproduce
Try to go below the limit of 50 subscriptions by setting subscriptions:null to some of the models in your schema.graphql file.

Expected behavior

  • Be able to have more than 50 subscriptions (which seems limited in iot core right now but shouldn't be for amplify). 17 entities is not that much for an application.
  • If there are less than 50 subscriptions on appsync, the code should be synchronized with the cloud and the warning should not appear. In other words, the attribute 'syncable' should be automatically set to false when subscriptions are 'null' or another way should be provided to allow to disable subscriptions for models properly.

Desktop (please complete the following information):

  • OS: Windows
  • Node Version: 12.13.1
AppSync DataStore Service Team

Most helpful comment

@undefobj
Same issue here, Cant believe theres a limit on this. It would also be much easier if this could be well stated in the documentation. This cause a total lockdown on us as developers.
Imagine I told and convince other programmers to use AWS- Data store. I think i will get telephone calls from the colleagues saying it was a bad move trying AWS. We hope the AWS Team can fix this soon

All 10 comments

@TheMoums thanks for the feedback

As a workaround I have decided to set some of the subscriptions in the models to 'null' wich results in less than 50 subscriptions in the compiled graphql (and on the appsync console). The frontend seems fine as the models have subscriptions: null as a property in schema.js in the 'models' folder.

Do you have a code snippet on how you are doing that?

@elorzafe
Of all my models, I had to choose 16 of them that would still have the offline capability provided by Datastore. For the others (like the example below) I had to sacrifice the offline sync

type BankAccount 
  @model(subscriptions: null) {
  id: ID!
  holder: String!
  number: String!
  clientId: ID!
}

When compiled with _amplify codegen models_ the 3 subscriptions (onCreate, onDelete, onUpdate) for this model disappear in the resulting schema.graphql. However my frontend seems to believe that there are still more than 50 subscriptions. Looking into my resulting _schema.js_, the following code is produced

"BankAccount": {
            "syncable": true,
            "name": "BankAccount",
            "pluralName": "BankAccounts",
            "attributes": [
                {
                    "type": "model",
                    "properties": {
                        "subscriptions": null
                    }
                }
            ],
            "fields": {
                "id": {
                    "name": "id",
                    "isArray": false,
                    "type": "ID",
                    "isRequired": true,
                    "attributes": []
                },
                "holder": {
                    "name": "holder",
                    "isArray": false,
                    "type": "String",
                    "isRequired": true,
                    "attributes": []
                },
                "number": {
                    "name": "number",
                    "isArray": false,
                    "type": "String",
                    "isRequired": true,
                    "attributes": []
                },
                "clientId": {
                    "name": "clientId",
                    "isArray": false,
                    "type": "ID",
                    "isRequired": true,
                    "attributes": []
                }
            }
        }

The subscriptions : null is correctly added to the properties of the model, but the warning that I have more than 50 subscriptions keeps showing up and the overall synchronization of all models is lost. The only way to force Amplify not to sync this model is to set the syncable property to false.

This seems to be working but the drawback of the illustrated method is losing the offline synchronization of some of your models and therefore not using the functions provided by Datastore (Datastore.save, ...). For the sacrificed models, one should instead use the API.graphql functions which interact fine with the dynamoDB tables but do not provide the offline capability provided by Amplify.

Is there a more effective workaround to keep Datastore synchronizing with more than 17 models (e.g. gathering onUpdate and onCreate subscriptions into only one)?
Is there a way to bypass this limit of 50 subscriptions which I believe is due to only one web socket connection open through AWS Iot?

The 50 subscription default limit is currently under review with the AppSync team to see if it might be raised, however in the interim you can cut a support ticket with your AWS account to ask for a raise.

@undefobj
We already raised a support case but we couldn鈥檛 get a positive response from the aws support. The limit is not available in the classical "service limit" options. So we created a case to ask for an increase but no response since 2 weeks.

@undefobj We had an answer from AWS
"I have an update from our internal team. The 50 subscriptions per client is a hard limit and unfortunately this cannot be increased. These limits are set to ensure proper availability of AWS resources, as well as to minimize billing risks for new customers, and modifying such hard limits can introduce significant challenges. I also requested the service team if this limit can be increased on demand as this issue is causing an inconvenience for your use-case. But unfortunately, this cannot be done."

Would it be possible to allow the possibility to combine subscriptions of the same entity to reduce the number of them? (e.g. allow to combine one onUpdate and one onCreate)
Or even open new web sockets when the limit of 50 subscriptions is reached?

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@undefobj @elorzafe
This limit is still a huge limitation for me.
Any news on this?

@undefobj We have just run into this issue as well. It is not well documented and we were not aware of this restriction when we decided on DataStore for our app. This is a showstopper for us. We don't have an issue with increased costs of hosting if that is what it requires to raise the limit above 50. We therefore request that this limit be allowed to be increased on a customer by customer basis, or otherwise that the hard limit be increased to at least 100.

@undefobj
Same issue here, Cant believe theres a limit on this. It would also be much easier if this could be well stated in the documentation. This cause a total lockdown on us as developers.
Imagine I told and convince other programmers to use AWS- Data store. I think i will get telephone calls from the colleagues saying it was a bad move trying AWS. We hope the AWS Team can fix this soon

Hello we have worked with the AppSync team and the limit has been doubled and fully deployed to all regions now. If you're still experiencing issues please do let us know.

Was this page helpful?
0 / 5 - 0 ratings