1. A method comprising: by a first computing device, determining one or more bandwidth constraints on a bandwidth of a communication channel between the first computing device and a second computing device; determining, by the first computing device, a number of data packets available to transmit from the first computing device to a second computing device, the determination based on the one or more bandwidth constraints and a payload capacity, each of the data packets having a payload with the payload capacity; by the first computing device, determining a plurality of data items to transmit from the first computing device to the second computing device; by the first computing device, determining, based on the one or more bandwidth constraints, whether to rank the data items; and when the items are determined to be ranked: by the first computing device, ranking each data item based at least on an affinity between a user and an originator of the data item in a social-networking system; by the first computing device, selecting, based at least in part on the ranking of the data items and the payload capacities of the data packets, one or more particular ones of the data items to transmit from the first computing device to the second computing device in the data packets; and by the first computing device, writing the particular ones of the data items to the payloads of the data packets.