The Internet consists of a huge number of different Internet service providers (ISP) exchanging traffic with each other. This traffic could, for instance, consist of an Internet user, connecting via an ADSL connection provided by an ISP, browsing to a Web server that is connected with a different ISP. This traffic exchange between Internet service providers is central for the Internet to function.

In order for traffic to reach from one operator to another, two things are required. On one hand, both operators must have a commercial agreement to exchange or convey traffic to other operators. This agreement does not differ too much from the agreement you and I have with our Internet service provider (ISP).
In addition to this, we also need a physical connection, much like a regular network cable, except that it is capable of handling much more traffic. This can be solved in three different ways.

The first way is used exclusively by big ISPs and based on exchanging traffic directly with another ISP. The physical connection is provided by the ISP who stands to gain the most on the traffic exchange. As a general rule, this is often the smaller one.

The second alternative is to connect to a hub. When you pay a fee to the hub, you can then exchange the traffic with as many other operators as you want without paying for more physical connections. There still needs to be a business agreement set up for each provider you want to Exchange traffic with. This method is used both by small and large ISPs.

The third alternative is to connect to an ISP who is connected to all other ISPs and therefore can sell traffic through these. This is commonly used as a starting point for smaller ISPs and as a last resort for larger ISPs. Usually, this is the option used first. It is only when the amount of traffic between two operators becomes big enough it is worthwhile to set up a direct connection. This is also the most common alternative when it comes to traffic on the Internet. This has to do with the fact that traffic is rarely forwarded to the few operators the ISP has agreements with. Usually it is forwarded to any of the other thousands of ISPs out there.

The first two options are called "peering" while the third is called "transit". Transit is generally more expensive than peering over a hub which in turn is more expensive than a direct peering. If you have enough traffic to a particular ISP it is cheaper to change to a peering connection.

A small ISP starts simply with a transit connection. When there is enough traffic to certain ISPs, the small ISP connects to a hub in order to then negotiate peering with these operators. Then, the same physical connection can be used to communicate with several other ISPs at the same time as the old transit connection is used to reach to the ISPs you are not peering with.

When traffic increases to certain ISPs, the ISP can choose to set up direct peering to them. This means that a separate physical connection is set up between the two ISPs. Even if the investment cost is higher, the operating cost will less than being connected via a hub.

Each ISP will then monitor the traffic that flows to and from the various ISPs. If too much traffic to a particular ISP goes through a transit connection, you switch to direct peering in order to save money. If the traffic patterns change, so does the the economic agreements.

So why is a specific connection slow to some sites but not to others? Well, depending on which route the traffic is directed, it is affected by the capacity and traffic load of that specific path at the moment. Companies providing service on the Internet (for example Google, Netflix, Spotify) are constantly working to provide a good and fast experience to as many users as possible, at all times. However, this does not always succeed. Take for example a Brazilian radio station streaming to Sweden. In that scenario it can be tough getting good performance when traffic must travel far and pass through many ISPs.