Person Re-Identification (Re-ID) aims to match the persons contained in surveillance videos, and is usually run on powerful servers in a supervised mode. However, centralized processing of massive video from thousands of cameras in a city is very costly and causes serious problems of privacy protection. Moreover, the labeling of numerous data for supervised training is also infeasible in this scenario. To address this problem, we propose a novel Self-optimizing Memory Network model, namely SoMem, which runs person Re-ID on edge devices in a totally unsupervised and distributed way. Specifically, SoMem adopts a random walk based collaborative training procedure to optimize the visual model on each camera based on locally collected images, and builds a distributed memory network to memorize and match the observed persons by using a distributed mutual ranking algorithm. Based on the cross-camera person matching results learned by the memory network, the visual models on edge devices are further optimized in a self-organized manner. Comprehensive experiments are conducted on several real person Re-ID datasets and deployed on edge devices to show the effectiveness and efficiency of this novel distributed Re-ID model.