Given an array of similar hosts, what are some of the advantages and disadvantages of zero padding or not?
Zero Padding
www-01
www-02
...
www-11
www-12
No Padding
www-1
www-2
...
www-11
www-12
I've seen both in practice and have heard reasons for/against each. The only snippet I've come across referencing zero padding is a small note in the Debian addclients manpage, but no reasoning:
"Padding hostnames with zeros is not recommended." Does anyone know what background or justification might be behind this recommendation?
Pros
- Simple alphanumeric sorting
- Fixed width
Cons
- Breaks down after the maximum padded id (99, 999, ...)
- Adds slight complexity to any comparison/validation (
^\w+-\d{
vs}$ ^\w+-\d+$
)
Answer
FWIW, we pad for consistency. That way we know that $hostname always has $x digits, so it saves a step. And saving 1 step on 3,000 machines goes a long way (about 1.5 miles, to be exact).
Of course, let's look at both sides. The Pros? For me it was discussed above. Host name consistency, and some people (myself included) enjoy looking at rows upon rows of host names that are all the same length, since I'm in charge of configuration here and all those machines with the exact same name are the exact same length in my spreadsheet and have the exact same configuration in real life. Ahh, what a relief.
The cons? The only one I can think of is that you make the padding too small, for instance padding 2 zeros and you wind up with over 100 hosts. What do you do? Forget about it? Rename the first 99 hosts? Making the padding too large really has no harm I can see, other than being able to use that space for something else (site code, workstation code, etc.).
Yes, in the end it's entirely up to you, but I think the votes on this answer will give the general community consensus, up or down.
No comments:
Post a Comment