|By Colin Walker||
|February 13, 2012 06:05 AM EST||
F5 uses TCL as the interpreter for iRules. Many people often ask why that is. This questions is usually followed up by an immediate, "Why not Perl?" or "Why not Java" or "Why not <fill in my preferred language of choice>?". I understand the question, and frankly I'm a Perl guy from way back myself, so when I first landed at F5 and started devouring all things iRules, I was curious about the same thing. Since then I've discussed this topic with some of F5's best, in my opinion, and have come to understand that there are many solid reasons for choosing the runtime that we use.
When asked "Why TCL?" my standard response centers around varying degrees of discussing:
These all remain true today, and I will expand on each of them in hopes of illuminating our position with TCL and iRules, and why the Perl lover in me was, and is to this day, convinced that we made the right choice.
Before I delve into the above list, first let me give some history of how we originally got to TCL in the first place. Originally, back in the days of dinosaurs and BIG-IP v3.0, when iRules was introduced as a technology within F5, we used a custom syntax. We hand rolled commands and utility functions, and relied on no particular language to achieve this, other than C, which is the base for pretty much everything that runs on our box, and frankly darn near everywhere else. This was all well and good, but as any F5 historian knows, the world changed a lot for us in v9.
For version 9 we tore up pretty much everything on the drawing board. Heck, we tore up the drawing board and started fresh. Even still, the plan was to go forward with the same approach, I.E. custom roll commands to be used within iRules and rely on no outside language to achieve this. At this point, though, some testing was done and a shocking result surfaced. In testing TCL against the custom built commands, TCL was actually faster in many cases. (More about how and why in a bit.) This left us with a very interesting fact: TCL was both faster and more feature rich than our hand rolled commands. That made the choice pretty simple.
Now then, on to the reasons why TCL was and still is a solid choice for iRules. From the list above, let’s start with speed.
We talk about it all the time. iRules are fast. Think of the fastest thing you can think of, a speeding bullet perhaps. Now think faster. No, faster than that. Seriously, blazingly fast. Why so much emphasis on speed? Because it lies at the core of everything that we do.
I’m one of the first people to say that it’s not all about speeds and feeds, as it were, when talking about ADC solutions from a broad perspective. That is not to be confused with the concept that speed is not important. Speed, in fact, is absolutely paramount when speaking from a granular level. The faster the granular functions are; packet interrogation, re-writing, routing, forwarding, IP translation, the faster each atomic function is, the less resources are utilized on such things. This leaves more power available as overhead to build and complete complex logical functions. Building business logic into the network could be costly to a point of making it prohibitive if it weren’t for the fact that each minute operation being performed behind the scenes were streamlined to the nth degree. So when it comes to iRules or any programmable interface for the network, speed is absolutely paramount.
That’s all well and good, but how does TCL fit into that? In testing TCL against other, heavier languages such as Perl and Python, we deemed pretty quickly two things:
1) TCL was far, far faster for our purposes than any of the other widely available options at the time, which is still the case with the exception of perhaps Lua.
2) Other options had large amounts of commands that we would either not need, or explicitly did not want to include for either security or performance reasons.
So out of the box TCL is a faster choice for our needs. If that weren’t enough, however, we also have to take into account the fact that we need to heavily modify the functionality of the language. For our purposes we both add and rip out large chunks of commands and functionality. We need to make things network aware, event driven (which, by the way, TCL explicitly is, and most other languages are not), add the notion of suspending/parking commands, ensure that garbage collection doesn’t occur in the middle of processing network traffic, and generally twist the language into something that understands what we are doing. TCL is very easy to modify in all of these ways, compared to other options, so this one more way in which it is a good fit for our needs.
Also keep in mind that the reality is, we’re only using a very small slice of what is available in whatever language iRules makes use of. This is because the vast majority of iRules commands are actually custom functions being performed within the TMM. Things like the HTTP:: commands, the table command, class, iStats, sideband connections … by far the lion’s share of what iRules users rely on for the functionality to understand, interpret and modify their traffic are actually calls to native C code. That is, those things don’t actually exist at all in the TCL world, beyond creating a TCL wrapper to call and handle the underlying functions.
This is for various reasons, not the least of which is – you guessed it – performance. The functions within TMM that perform these actions are far higher performance in their native state than they could be in any interpreted language running per connection, TCL or otherwise. So if a huge majority of our commands are actually just passing control back and forth between TCL and C, then a highly adept interface for doing so becomes paramount. TCL, again, pulls ahead of the pack in this arena. It just so happens that TCL has one of the more thorough C programming APIs available, compared to other similar language options. Given how often this happens and how important it is to what iRules does at its core, this is a big plus.
Last but not least, TCL supports the notion of compiling to byte-code. This is something we make extensive use of to boost performance at run time. Whenever an iRule is saved to the system it is compiled into byte code, which allows it to execute far faster than if it were in the native, human readable state. Most scripting languages combine the compilation and execution functions so that both occur effectively at the same time. With TCL we're able to use a different model that allows for the compilation, syntax checking etc. to occur at load time, which means that at run time, the byte code is processed instead of the original iRule, thus skipping a large amount of the overhead that would otherwise be involved. This allows a far smaller footprint at run time (meaning when the iRule has to execute), in exchange for a bit of extra work at load time (when a user saves an iRule), which is a very, very solid trade for us. Anything we can offload to happen once at load time rather than for each connection that comes through the system is an extremely solid performance improvement. 1 execution per save vs 100k executions per second (on a highly traffic laden box) is a pretty simple picture to understand, and bytecode allows us to achieve that at least somewhat.
TCL is not only extremely fast, but also supremely embeddable. It has a long history of being a go-to embedded interpreter in many fast paced, low level systems such as L2 switches. This is thanks to the fact that TCL is very, very small, when compared to other languages that offer similar functionality (or more functionality, like Perl and Java, but more on that later). Also, TCL is amazingly simple to integrate with C. So much so that it is considered near free in many cases, and anything written in C could easily be exposed via TCL with minimal effort. Keep in mind here that when I talk about things written in C, that list includes a massive array of programs and systems, including many modern kernels, such as Windows and Linux. TCL being friendly with kernels isn’t a bad thing when looking at integrating it with a custom micro-kernel, as is the case within TMM.
On top of the highly embeddable nature of TCL, you also have to factor in the absolutely minuscule footprint. The entirety of TCL is a few hundred kilobytes, including the parts we’re not using within iRules. That is tiny in comparison to its more feature rich cousins Perl and Java and <many others>. For instance the entire source download of TCL (as of the writing of this article) is 4.3M whereas Perl is 15M. The size of the environment becomes very important the more you understand the inner workings of the iRules world.
One of the things that most people don’t take into account or don’t realize is the fact that each connection to the BIG-IP that invokes an iRule receives a unique TCL context along with the accompanying state, variables, etc. This means that memory is allocated to every connection that uses an iRule to store that TCL structure, allow it to interface uniquely with TMM, and do what it needs for that particular connection and the iRules associated with it. Keep in mind that this can occur millions of times concurrently on a busy, high-end F5 device, and to me it becomes extremely impressive. The memory footprint difference between a couple hundred kilobytes for TCL and a couple megabytes for many other languages is large enough for a single instance. When you talk about a few hundred thousand or even a million concurrent instances, however, it becomes exponentially larger and more important, as you might imagine.
Surely you could not allocate, store, and process millions of copies of Perl in the same resource footprint. This is directly due to the size and simplicity of TCL. Perl and other such languages have many, many more base capabilities than TCL. This is a fantastic thing when and if you need them, and when you aren’t worried about resource constraints in such a blisteringly fast paced environment. In our world, when the vast majority of that added functionality isn’t needed anyway, and every byte or cycle counts, the overhead isn’t nearly worth the luxury.
One of the best engineers here at F5, from whom I gleaned some fantastic insight and new information when asking questions to help inspire this conversation, said it quite well:
“The full Tcl syntax can be described by just a handful of rules. In fact it's so simple you could write your own Tcl grammar parser in an afternoon. For contrast, only Perl can parse Perl.”
Don’t get me wrong, I’m a big Perl fan, and still use it to this day for writing utilities and such on the command line. There is a tool for every job and in our particular case, given the performance requirements we have, TCL just makes more sense.
Now that we understand the performance concerns and how TCL plays well in that arena, the next most prominent concern on our list would be usability. When considering usability in this case it is important to remember our target audience. The people generally managing these systems are not full time programmers. As such, making use of a simple, easily readable language that is quick to pick up and master, and easy to read and pass from one user to the next makes a lot of sense.
The simplicity of TCL plays into less overhead to the user when it comes to understanding the commands and tools available just as much as it plays into the system overhead required to load. It makes sense, I think, that a language with far greater capabilities and extended commands, memory structures, modules, etc. would take more time and effort to master. Given that doing so is often not the primary role of the individuals we hope to appeal to with iRules, the simpler approach makes more sense.
On top of that, most of that added functionality simply isn’t necessary. Keep in mind we’re not even exposing all of TCL. We intentionally and specifically limit some of the base functionality. If we are limiting the much simpler, less complex language because we don’t need or want that functionality, there is little argument for moving to a more complex, feature rich language, given that the majority of the functionality would likely be “nice to have” at best, and undue overhead at worst.
Is TCL still the right choice?
All of that being said, if we were starting from scratch today without thousands of iRules in the wild, a community built up to support the language, TMSH, iApps and many other technologies within the BIG-IP making use of TCL, etc. would we choose TCL again?
Given the needs iRules has for an interpreter: Fast, tightly embeddable, small footprint, fast, easily tied to native C and thus kernels, usability – yes, I think TCL would still be a strong contender for being the best fit for our needs. If I weren’t convinced of it before, I’ve spoken to some of the core architects responsible for iRules today, and they share the same opinion, that TCL is still as strong a choice today as it was in 2004. There are others that offer similar benefits today, Lua being chief among them, but there are drawbacks of those as well. To me, there is no clearly superior choice for our very specific needs even in today’s landscape. On top of that, we rarely get any complaints about iRules being TCL based. Sure we get questions as to why, but once we explain the benefits and people are clear on the reasons we went down the road we did, it almost always results in a happy iRules user.
Are there some ways in which allowing users access to other languages may be beneficial? Certainly, but keep in mind they are largely available. It is quite commonplace for Perl and bash to be used for monitors already. Perhaps a better way of addressing the question is: What is it you would like to do with other languages that you cannot via iRules currently? Once that is understood, the discussion could turn to whether or not that is possible, feasible and reasonable to implement within BIG-IP in some fashion. Would this be built directly into the TCL construct iRules is based on, or in some other fashion that may allow the use of a chosen language, or a subset thereof? Who knows, but it is a valuable conversation regardless of the outcome. The more we can understand what it is people would like to and are trying to do, the better we can continue expanding the already powerful tools that we offer to meet those needs.
Hopefully that paints the picture of why we chose and continue to use TCL to support our powerful iRules framework. I am not by any means a TCL zealot. Frankly I had far more experience in other languages before coming to F5, and rather enjoyed writing things in those languages. What I care about far more than writing in my favorite language, however, is using the right tool for the job. As I’ve learned more about iRules I have come to understand the reasons we use TCL to do what we do, and appreciate what it allows us.
The Internet of Everything (IoE) brings together people, process, data and things to make networked connections more relevant and valuable than ever before – transforming information into knowledge and knowledge into wisdom. IoE creates new capabilities, richer experiences, and unprecedented opportunities to improve business and government operations, decision making and mission support capabilities.
Jul. 29, 2015 03:15 PM EDT Reads: 232
The Internet of Things is not only adding billions of sensors and billions of terabytes to the Internet. It is also forcing a fundamental change in the way we envision Information Technology. For the first time, more data is being created by devices at the edge of the Internet rather than from centralized systems. What does this mean for today's IT professional? In this Power Panel at @ThingsExpo, moderated by Conference Chair Roger Strukhoff, panelists addressed this very serious issue of profound change in the industry.
Jul. 29, 2015 03:00 PM EDT Reads: 1,251
Discussions about cloud computing are evolving into discussions about enterprise IT in general. As enterprises increasingly migrate toward their own unique clouds, new issues such as the use of containers and microservices emerge to keep things interesting. In this Power Panel at 16th Cloud Expo, moderated by Conference Chair Roger Strukhoff, panelists addressed the state of cloud computing today, and what enterprise IT professionals need to know about how the latest topics and trends affect their organization.
Jul. 29, 2015 02:00 PM EDT Reads: 1,163
SYS-CON Events announced today that HPM Networks will exhibit at the 17th International Cloud Expo®, which will take place on November 3–5, 2015, at the Santa Clara Convention Center in Santa Clara, CA. For 20 years, HPM Networks has been integrating technology solutions that solve complex business challenges. HPM Networks has designed solutions for both SMB and enterprise customers throughout the San Francisco Bay Area.
Jul. 29, 2015 01:45 PM EDT Reads: 417
For IoT to grow as quickly as analyst firms’ project, a lot is going to fall on developers to quickly bring applications to market. But the lack of a standard development platform threatens to slow growth and make application development more time consuming and costly, much like we’ve seen in the mobile space. In his session at @ThingsExpo, Mike Weiner, Product Manager of the Omega DevCloud with KORE Telematics Inc., discussed the evolving requirements for developers as IoT matures and conducted a live demonstration of how quickly application development can happen when the need to comply wit...
Jul. 29, 2015 07:30 AM EDT Reads: 278
Explosive growth in connected devices. Enormous amounts of data for collection and analysis. Critical use of data for split-second decision making and actionable information. All three are factors in making the Internet of Things a reality. Yet, any one factor would have an IT organization pondering its infrastructure strategy. How should your organization enhance its IT framework to enable an Internet of Things implementation? In his session at @ThingsExpo, James Kirkland, Red Hat's Chief Architect for the Internet of Things and Intelligent Systems, described how to revolutionize your archit...
Jul. 28, 2015 06:30 PM EDT Reads: 1,374
It is one thing to build single industrial IoT applications, but what will it take to build the Smart Cities and truly society-changing applications of the future? The technology won’t be the problem, it will be the number of parties that need to work together and be aligned in their motivation to succeed. In his session at @ThingsExpo, Jason Mondanaro, Director, Product Management at Metanga, discussed how you can plan to cooperate, partner, and form lasting all-star teams to change the world and it starts with business models and monetization strategies.
Jul. 28, 2015 04:30 PM EDT Reads: 1,753
Converging digital disruptions is creating a major sea change - Cisco calls this the Internet of Everything (IoE). IoE is the network connection of People, Process, Data and Things, fueled by Cloud, Mobile, Social, Analytics and Security, and it represents a $19Trillion value-at-stake over the next 10 years. In her keynote at @ThingsExpo, Manjula Talreja, VP of Cisco Consulting Services, discussed IoE and the enormous opportunities it provides to public and private firms alike. She will share what businesses must do to thrive in the IoE economy, citing examples from several industry sectors.
Jul. 28, 2015 11:00 AM EDT Reads: 2,031
Growth hacking is common for startups to make unheard-of progress in building their business. Career Hacks can help Geek Girls and those who support them (yes, that's you too, Dad!) to excel in this typically male-dominated world. Get ready to learn the facts: Is there a bias against women in the tech / developer communities? Why are women 50% of the workforce, but hold only 24% of the STEM or IT positions? Some beginnings of what to do about it! In her Opening Keynote at 16th Cloud Expo, Sandy Carter, IBM General Manager Cloud Ecosystem and Developers, and a Social Business Evangelist, d...
Jul. 27, 2015 09:00 PM EDT Reads: 2,038
There will be 150 billion connected devices by 2020. New digital businesses have already disrupted value chains across every industry. APIs are at the center of the digital business. You need to understand what assets you have that can be exposed digitally, what their digital value chain is, and how to create an effective business model around that value chain to compete in this economy. No enterprise can be complacent and not engage in the digital economy. Learn how to be the disruptor and not the disruptee.
Jul. 27, 2015 10:00 AM EDT Reads: 2,020
Akana has released Envision, an enhanced API analytics platform that helps enterprises mine critical insights across their digital eco-systems, understand their customers and partners and offer value-added personalized services. “In today’s digital economy, data-driven insights are proving to be a key differentiator for businesses. Understanding the data that is being tunneled through their APIs and how it can be used to optimize their business and operations is of paramount importance,” said Alistair Farquharson, CTO of Akana.
Jul. 27, 2015 09:00 AM EDT Reads: 311
Business as usual for IT is evolving into a "Make or Buy" decision on a service-by-service conversation with input from the LOBs. How does your organization move forward with cloud? In his general session at 16th Cloud Expo, Paul Maravei, Regional Sales Manager, Hybrid Cloud and Managed Services at Cisco, discusses how Cisco and its partners offer a market-leading portfolio and ecosystem of cloud infrastructure and application services that allow you to uniquely and securely combine cloud business applications and services across multiple cloud delivery models.
Jul. 27, 2015 08:00 AM EDT Reads: 1,892
The enterprise market will drive IoT device adoption over the next five years. In his session at @ThingsExpo, John Greenough, an analyst at BI Intelligence, division of Business Insider, analyzed how companies will adopt IoT products and the associated cost of adopting those products. John Greenough is the lead analyst covering the Internet of Things for BI Intelligence- Business Insider’s paid research service. Numerous IoT companies have cited his analysis of the IoT. Prior to joining BI Intelligence, he worked analyzing bank technology for Corporate Insight and The Clearing House Payment...
Jul. 26, 2015 09:00 PM EDT Reads: 1,559
In his keynote at 16th Cloud Expo, Rodney Rogers, CEO of Virtustream, discussed the evolution of the company from inception to its recent acquisition by EMC – including personal insights, lessons learned (and some WTF moments) along the way. Learn how Virtustream’s unique approach of combining the economics and elasticity of the consumer cloud model with proper performance, application automation and security into a platform became a breakout success with enterprise customers and a natural fit for the EMC Federation.
Jul. 26, 2015 08:00 AM EDT Reads: 2,141
"Optimal Design is a technology integration and product development firm that specializes in connecting devices to the cloud," stated Joe Wascow, Co-Founder & CMO of Optimal Design, in this SYS-CON.tv interview at @ThingsExpo, held June 9-11, 2015, at the Javits Center in New York City.
Jul. 25, 2015 02:00 PM EDT Reads: 381
SYS-CON Events announced today that CommVault has been named “Bronze Sponsor” of SYS-CON's 17th International Cloud Expo®, which will take place on November 3–5, 2015, at the Santa Clara Convention Center in Santa Clara, CA. A singular vision – a belief in a better way to address current and future data management needs – guides CommVault in the development of Singular Information Management® solutions for high-performance data protection, universal availability and simplified management of data on complex storage networks. CommVault's exclusive single-platform architecture gives companies unp...
Jul. 25, 2015 01:00 PM EDT Reads: 1,945
Electric Cloud and Arynga have announced a product integration partnership that will bring Continuous Delivery solutions to the automotive Internet-of-Things (IoT) market. The joint solution will help automotive manufacturers, OEMs and system integrators adopt DevOps automation and Continuous Delivery practices that reduce software build and release cycle times within the complex and specific parameters of embedded and IoT software systems.
Jul. 25, 2015 12:15 PM EDT Reads: 446
"ciqada is a combined platform of hardware modules and server products that lets people take their existing devices or new devices and lets them be accessible over the Internet for their users," noted Geoff Engelstein of ciqada, a division of Mars International, in this SYS-CON.tv interview at @ThingsExpo, held June 9-11, 2015, at the Javits Center in New York City.
Jul. 25, 2015 12:00 PM EDT Reads: 1,521
Internet of Things is moving from being a hype to a reality. Experts estimate that internet connected cars will grow to 152 million, while over 100 million internet connected wireless light bulbs and lamps will be operational by 2020. These and many other intriguing statistics highlight the importance of Internet powered devices and how market penetration is going to multiply many times over in the next few years.
Jul. 25, 2015 09:00 AM EDT Reads: 1,480
SYS-CON Events announced today that Dyn, the worldwide leader in Internet Performance, will exhibit at SYS-CON's 17th International Cloud Expo®, which will take place on November 3-5, 2015, at the Santa Clara Convention Center in Santa Clara, CA. Dyn is a cloud-based Internet Performance company. Dyn helps companies monitor, control, and optimize online infrastructure for an exceptional end-user experience. Through a world-class network and unrivaled, objective intelligence into Internet conditions, Dyn ensures traffic gets delivered faster, safer, and more reliably than ever.
Jul. 24, 2015 11:00 PM EDT Reads: 2,047