Detecting Collision with Large Numbers of Simple Objects

In a project I am working on I need to create a large number (thousands) of simple identical objects (spheres) that float upwards at a constant velocity. There are “animals” in the world that feed off of these objects, and so need to detect which ones are in range and then eat the object on collision. Having thousands of objects with attached colliders and having each animal track nearby food and check for collisions is obviously very expensive and is currently bringing my FPS to a halt.

So, what are some tricks I can use to handle this? Here are some constraints that could dictate viable solutions:

Food pieces move at a constant velocity and don’t need to respond to ANY collisions besides being destroyed when an animal touches them.
Animals need to be able to detect their closest food source, move towards it, and destroy it upon collision. The collision does not have to be pixel perfect.
Food pieces are 1-2m in size, animals range from 2m-11m.
Animals and food pieces are roughly evenly distributed in a 5000mX5000mX5000m box.

Thank you in advance for any help.

As @MJMC suggests, you should have an Object Pool, only if you regenerate food though, otherwise it would be pointless. But that won’t be the issue here. The issue would be is finding the closest food object, that will impact your performance big time. Judging by the number of your objects i would divide the space into smaller chunks, just as Minecraft does. The chunk would be a cube with a trigger collider that would know what food particles are inside of it. Then the object would basically know in what chunk it is (collides with it), it could look through the food available in that chunk. For speed i suggest you store all the food references for that chunk in an array. You could also make it so the chunks know about their neighbors, so that when food is getting low, your animals can go to another neighboring chunk.