Closed alanshaw closed 2 months ago
@hannah will review today!
... and I don't fully understand the diff between EIPFSService & IPNIService
The IPNI stack was consuming the E-IPFS stack. I just separated them out incase we wanted to use any E-IPFS stack components in other stacks. In hindsight I think it's unlikely.
In general we separate out stacks to avoid circular dependencies. e.g. we have an upload-api
stack and a upload-db
. The billing
stack uses the upload-db
stack. The upload-api
stack uses the billing
stack AND the upload-db
stack. This wouldn't be possible if the DB was not a separate stack.
This PR fixes an issue where a call to
space/index/add
does not have enough time to complete with the timeout forced by AWS API Gateway (29s).When a CAR file has many thousands of blocks, it can take >29s to write all the blocks to the old E-IPFS dynamo table and to the E-IPFS multihashes queue (which feeds IPNI advertisements).
Previously looking at the exectuion times for lambdas I considered this possible, but clearly I did not encounter an upload with thousands fo blocks in the time window I observed.
The PR introduces an IPNI stack. It currently consists of 2 queues and 2 lambda consumers. 1 queue is for IPNI and the other is for writing to dynamo.
Before
The issue is:
This times out for indexes of many thousands of entries and causes the API Gateway service to respond with 503.
After
The solution is to create queues that allow messages to be sent to them with many items per message. The queue consumers then use batch sends to write to existing E-IPFS mutlihashes queue and dynamo table.
Each lambda consumer gets 15 minutes to execute which should be more than enough time to write to their targets.
Note this essentially re-introduces an unknown async time between index/add and the data becoming available on the gateway due to the queue. ...which I had hoped to avoid with the transition to the blob protocol.