Major cities across the U.S. have sensors throughout their highways, and they use this to measure the average vehicle speed in various sections. The data is used to automate warnings on highway signs, control traffic light flow, etc.
The data is made available for public use, and is usually updated every two minutes or so.
I do not know how often Google maps checks it.