Owing to the fast deployment of distributed energy resources (DERs) and the further development of demand-side management, small agents in electricity markets are becoming more proactive. This may boost the development of peer-to-peer (P2P) market mechanisms. Meanwhile, since actual load and power generation may substantially deviate from schedules obtained at the day-ahead (forward) market stage, it is needed to rapidly reschedule the trades among agents to maintain power balance through a real-time market mechanism, also in a P2P framework. However, it is technically challenging to develop and operate such P2P market mechanisms in real-time, since they most often involve a heavy computational burden (e.g., based on iterative distributed optimization approaches), while real-time trading demands fast calculation. Our core contribution is hence to describe and analyze a novel online optimization framework to enable the real-time P2P market. It relies on online social welfare maximization using a novel online consensus alternating direction method of multipliers (OC-ADMM) algorithm. The computational complexity is then heavily reduced since only one iteration is performed for each agent at every time step in order to satisfy real-time requirements. We derive a sublinear non-stationary regret upper bound for our algorithm, which implies that social welfare will be maximized in the long run. Simulations based on a number of case studies show that our algorithm has good convergence performance, tracking ability, and high computational efficiency.