you could use a ring buffer, e.g.
https://www.embedded.com/electronics-blogs/embedded-round-table/4419407/The-ring-buffer
even if data flow speed is variable so long as you can empty the buffer before it becomes full there is no problem
what happens when you get overflow (buffer full) ? could you
1. thorw away the oldest data?
2. ignore some of the imcomming data?
3. implement hardware or software flow control?
what processing do you have to do on the incomming data?