We are building a Log aggregator for functions on S3, here is the algorithm I am thinking for this -
1. Append log lines to a blob and track the object size and Etag at that point from the responsse
2. Write the object size and etag in FoundationDB
3. When new log line comes in, use the object size recorded as the offset to append to the same object
4. Use Etag for conditional writes so multiple servers are not appending to the same offset if the log lines are sent to two different servers
5. If a server fails to append to the key, it will retry again by reading the latest etag and offset from FDB
6. We risk losing some log lines if the server handling the log line crashes before it can write to S3
7. Log lines can be stored out of order depending because of optimistic concurrency across servers
Thoughts? Very basic but I think this gets the job done especially we are relaxing some rules around ordering and losing data