5

One of my professors was telling us about scalability problems, and said that the X protocol was a prime example of a not scalable protocol. Why is that? Is it because it is very hardware dependent? I know that X is used in modern unix/linux environments, if it's not scalable than why is it used so widely?

  • re: the title, Xorg suffers, period. – strugee Sep 17 '13 at 0:39
  • 5
    In X's defense, I'd like to point out that the poor thing was born in 1984 and is running today on my laptop. Staying power has to count for something! – terdon Sep 17 '13 at 0:42
  • also, the reason it's used widely is because it used to be awesome (nowadays people hate it). there is a project called Wayland that is slated to replace Xorg, and also one called Mir (but that's only going to be used in Unity running on Ubuntu). youtube.com/watch?v=RIctzAQOe44 may also be of interest. – strugee Sep 17 '13 at 0:43
  • 3
    My answer was my no means meant to slam X. This would be equivalent of using us still using the Apollo mission equipment to go into outer space today. I hope anything I make in my lifetime can last this long! – slm Sep 17 '13 at 0:56
6

One reason he may have said this is that if you look at the traffic that flows back and forth between a client and a server, it's fairly verbose. This doesn't present an issue when the traffic is only having to go locally on a single box between the 2, however when the traffic needs to go over a network connection, then it becomes more painfully obvious that it's an inefficient protocol.

The protocol is tolerable on a LAN network, but as soon as you try and span it over a WAN connection, or introduce encryption in the form of a VPN or by using an SSH connection as a link between the client and the server, the Protocol really starts to show it's lack of scalability.

Benchmarking

You can use the tool x11perf to get a sense of the impact of running the applications localhosted vs. running them over an SSH connection to another X system.

Here I'm running the -create test to give you a taste of what I'm talking about.

localhost

$ x11perf -create
x11perf - X11 performance program, version 1.2
Fedora Project server version 10905000 on :0.0
from grinchy
Mon Sep 16 21:08:28 2013

Sync time adjustment is 0.1340 msecs.

   2400 reps @   0.0134 msec ( 74400.0/sec): Create and map subwindows (4 kids)
   2400 reps @   0.0156 msec ( 64300.0/sec): Create and map subwindows (4 kids)
   ....
   2400 reps @   0.0119 msec ( 83800.0/sec): Create and map subwindows (100 kids)
  12000 trep @   0.0063 msec (158000.0/sec): Create and map subwindows (100 kids)
   ....
   2400 reps @   0.0029 msec (349000.0/sec): Create and map subwindows (200 kids)
  12000 trep @   0.0049 msec (205000.0/sec): Create and map subwindows (200 kids)

LAN host

$ ssh skinner "x11perf -create"
....    
Sync time adjustment is 1.5461 msecs.

   2400 reps @   0.0270 msec ( 37100.0/sec): Create and map subwindows (4 kids)
   2400 reps @   0.0219 msec ( 45700.0/sec): Create and map subwindows (4 kids)
   ....
   2400 reps @   0.0168 msec ( 59600.0/sec): Create and map subwindows (100 kids)
  12000 trep @   0.0211 msec ( 47300.0/sec): Create and map subwindows (100 kids)
   ....
   2400 reps @   0.0159 msec ( 62900.0/sec): Create and map subwindows (200 kids)
  12000 trep @   0.0196 msec ( 50900.0/sec): Create and map subwindows (200 kids)

WAN host

$ ssh catbus-o "x11perf -create"
....
Mon Sep 16 21:12:22 2013

Sync time adjustment is 27.9911 msecs.

   2400 reps @   0.0592 msec ( 16900.0/sec): Create and map subwindows (4 kids)
   2400 reps @   0.0604 msec ( 16600.0/sec): Create and map subwindows (4 kids)
   ....
   2400 reps @   0.0538 msec ( 18600.0/sec): Create and map subwindows (100 kids)
  12000 trep @   0.0558 msec ( 17900.0/sec): Create and map subwindows (100 kids)
   ....
   2400 reps @   0.0697 msec ( 14400.0/sec): Create and map subwindows (200 kids)
  12000 trep @   0.0586 msec ( 17100.0/sec): Create and map subwindows (200 kids)

Notice the extreme drop off from:

localhost:

  12000 trep @   0.0049 msec (205000.0/sec): Create and map subwindows (200 kids)

LAN host:

  12000 trep @   0.0196 msec ( 50900.0/sec): Create and map subwindows (200 kids)

WAN host:

  12000 trep @   0.0586 msec ( 17100.0/sec): Create and map subwindows (200 kids)

That's a pretty steep decline in performance. Now realize that this isn't all X's fault. It is going over a 100MB network in the LAN test, and a ~20MB connection for the WAN test, but the point is still the same. X isn't helping itself with it's overly beefy communications it's throwing back and forth between the X server and the X client.

Communications Breakdown (couldn't resist the Led Zeppelin reference)

This is more for effect but just to give you an idea of the amount of data that's roughly flowing back and forth during the x11perf -create test that I used above I decided to run it on my LAN host again, only this time I used tcpdump to capture the SSH traffic, and dump it to a file.

I used this command:

$ sudo -i
$ tcpdump -lnni wlan0 -w dump.log -s 65535 host skinner and port ssh

The resulting log file:

$ ll dump.log 
-rw-r--r-- 1 root root 5768821 Sep 16 22:30 dump.log

So the resulting amount of traffic was in the ballpark of ~5.5MB. Granted this is not all X traffic but it gives you an idea of the amount of data flowing. This is really the Achilles' heel of X, and the major reason why it can't scale.

  • A single connection slow over a WAN is not lack of scalability. Scalability is not a magic word that can be used in place of other metrics like responsiveness, usability, efficiency, etc. Scalability means the degree to which the performance per unit load stays the same as we increase the load (number of connections, number of database transactions, number of users, etc). – Kaz Sep 17 '13 at 6:01
  • @Kaz - agreed, was only trying to give the OP a sense of why X struggles to scale (the smoke), not so much all the gore details (the file). – slm Sep 17 '13 at 6:14
  • great answer, a lot of good stuff in there for me to read through. Thanks for going above and beyond the call of duty on this one. I love the SE sites. If I could check this answer again I would :) – SetSlapShot Sep 17 '13 at 12:07
  • 1
    @SetSlapShot - thanks. Keep asking insightful Q's, and good luck with your school work! – slm Sep 17 '13 at 12:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.