1 \documentclass[preprint,10pt]{sigplanconf}
5 \usepackage[british]{babel}
10 \newcommand{\cL}{{\cal L}}
13 \conferenceinfo{ScalaDays '12}{London, UK.}
15 \copyrightdata{1-59593-056-6/05/0006}
17 \titlebanner{DRAFT---Do not distribute}
21 \title{Aquarium: Billing for the Cloud in the Cloud}
23 \authorinfo{Georgios Gousios \and Christos KK Loverdos}
25 {\{gousiosg,loverdos\}@grnet.gr}
29 This paper describes the architecture for the Aquarium cloud infrastructure
33 \category{D.3.3}{Programming Languages}{Language Constructs and Features}[Control structures]
36 Object-Oriented Programming, Philosophy
39 OOP, Ontology, Programming Philosophy
41 \section{Introduction}
42 \section{Requirements}
44 Aquarium was designed on a clean sheet to serve a particular purpose,
45 namely the provision of billing services to an IaaS infrastructure,
46 and also be extensible to new services. In the following sections,
47 we briefly present the requirements that shaped Aquarium's design.
49 \subsection{Application Environment}
50 Aquarium developed as part of the Okeanos project at GRNet. The
51 Okeanos project is building a full stack public IaaS system for Greek
52 universities, and several services on top of it. Several components comprise
53 the Okeanos infrastructure:
57 \item[Synnefo] is an IaaS management console. Users can create and start
58 VMs, monitor their usage, create private internal networks among VMs
59 and connect to them over the web. The service backend is based on
60 Google's Ganneti for VM host management and hundrends of physical
63 \item[Archipelago] is a storage service, based on the Rados
64 distributed object store. It is currently under development, and the
65 plan is to act as the single point of storage for VM images, shared
66 volumes and user files, providing clonable snapshots and distributed
69 \item[Pithos] is a user oriented file storage service. Currently it its
70 second incarnation, it supports content deduplication, sharing of files
71 and folders and a multitude of clients.
73 \item[Astakos] is an identity consolidation system that also acts as the
74 entry point to the entire infrastructure. Users can login using
75 identities from multiple systems, such as the Shibboleth (SAML)
76 federation enabled across all Greek universities or their Twitter
81 While all the above systems (and several prospective ones) have different
82 user interfaces and provide distinct functionality in the context of
83 the GRnet IaaS, they all share a common notion of \emph{resources}, access
84 and manipulation options to which they offer to users.
86 \subsection{Supported Users}
88 The Okeanos IaaS will support the Greek higher education, an estimated
89 population of 100.000 students and researchers. Each member will be granted
90 access to a collection of resources using her institutional account. To enforce
91 a limit to the resources that can be acquired from the platform, each user will
92 have a limited amount of credits, renewable each month, which will be allowed
93 to spend on any resource available through the infrastructure. Resources can
94 also be shared; for example files on the Pithos file service or virtual machine
95 images on the Archipelago storage can be
98 \subsection{Configuration}
100 Billing systems are by nature open ended. As new services are deployed, new
101 resources appear, while others might be phased out. Moreover, changes to
102 company policies may trigger changes to price lists for those resources, while
103 ad-hoc requests for large scale computational resources may require special
104 pricing policies. In order for a billing system to be able to successfully
105 adapt to changing requirements, it must be able to accommodate such changes
106 without requiring changes to the application itself. This means that all
107 information required for Aquarium in order to perform a billing operation,
108 must be provided to it externally. Moreover, to ensure high-availability,
109 billing configuration should be updatable while Aquarium is running, or at
110 least with minimal downtime, without affecting the operation of external
116 In the context of the Okeanos system, Aquarium provides billing services on a
117 per user basis for all resources exposed by other systems. As such, it is in
118 the critical path of user requests that modify resource state; all supported
119 applications must query Aquarium in order to ensure that the user has enough
120 credits to create a new resource. This means that for a large number of users
121 (given previous GRNet systems usage by the Greek research community, we
122 estimate a concurrency level of 30.000 users), Aquarium must update and
123 maintain in a queryable form their credit status,
124 with soft realtime guarantees.
126 Being on the critical path also means that Aquarium must be highly resilient,
127 too. If Aquarium fails, all supported systems will also fail. Even if Aquarium
128 fails for a short period of time, it must not loose any billing events, as this
129 will allow users to use resources without paying for them. Moreover, in case of
130 failure, Aquarium must not corrupt any billing data under any circumstances,
131 while it should reach an operating state very fast after a service restart.
133 \section{Architecture}
137 \section{Implementation}
139 \subsection{The configuration DSL}
141 The configuration requirements presented above were addressed by creating a new
142 domain specific language ({\sc dsl}), based on the YAML format. The DSL
143 enables administrators to specify billable resources, billing policies and
144 price lists and combine them arbitrarily into agreements applicable to specific
145 users, user groups or the whole system.
146 The DSL supports inheritance for policies, price lists and agreements and composition in the case of agreements.
147 It also facilitates the
148 definition of generic, repeatable debiting rules, which are then used by the
149 system to refill the user's account with credits on a periodic based.
151 The DSL is in itself based on five top-level entities, namely:
155 \item[Resources] specify the properties of resources that Aquarium knows
156 about. Apart from the expected ones (name, unit etc),
157 a resource has two properties that affect billing: \textsf{costpolicy}
158 defines whether the billing operation is to be performed at the moment
159 a billing event has arrived, while the \textsf{complex} attribute defines
160 whether a resource can have many instances per user.
162 \item[Pricelists] assign a price tag to each resource, within a timeframe.
164 \item[Algorithms] specify the way the billing operation is done in response
165 to a billing event. The simplest (and default) way is to multiply the
166 billable quantity with the applicable price. To enable more complex billing
167 scenarios, the Aquarium DSL supports a simple imperative language with
168 a number of implicit variables (e.g. \texttt{price, volume, date})
169 that enable administrators to specify, e.g. billing algorithms that
170 scale with billable volume. Similarily to pricelists, algorithms
171 have an applicability timeframe attached to them.
173 \item[Crediplans] define a number of credits to give to users and a repetition
176 \item[Agreements] assign a name to algorithm, pricelist and creditplan triplets,
177 which is then assigned to each user.
183 \lstset{language=ruby, basicstyle=\footnotesize,
184 stringstyle=\ttfamily,
185 flexiblecolumns=true, aboveskip=-0.9em, belowskip=0em, lineskip=0em}
193 costpolicy: continuous
206 - start: "00 02 * * Tue"
208 from: 1326041177 #Sun, 8 Jan 2012 18:46:27 EET
212 bandwidthup: $price times $volume
217 name: scaledbandwidth
221 if $volume gt 15 then
223 elsif $volume gt 15 and volume lt 30 then
224 $volume times $price times 1.2
226 $volume times price times 1.4
230 \caption{A simple billing policy definition.}
234 In Figure~\ref{fig:dsl}, we present the definition of a simple (albeit valid)
235 policy. The policy parsing is done top down, so the order of definition
236 is important. The definition starts with a resource, whose name is then
237 re-used in order to attach a pricelist and a price calculation algorith to it.
238 In the case of pricelists, we present an example of \emph{temporal overloading};
239 the \texttt{everyTue2} pricelist overrides the default one, but only for
240 all repeating time frames between every Tuesday at 02:00 and Wednesday at
241 02:00, starting from the timestamp indicated at the \texttt{from} field. Another
242 example of overloading is presented at the definition of the agreement, which
243 overloads the default algorithm definition using the imperative part of the
244 Aquarium {\sc dsl} to provide a scaling charge algorithm.
248 As common to most similar systems, billing in Aquarium is the application of
249 a billing contract to an incoming billing event in order to produce an
250 entry for the user's wallet. However, in stark contrast to most other systems,
251 which rely on database transactions in order to securely modify the user's
252 balance, Aquarium performs account updates asynchronously and concurrently
255 Billing events are obtained by a connection to a reliable message queue.
256 The billing event format depends on the
257 The actual format of the event is presented in Figure~\ref{fig:resevt}.
260 \lstset{language=C, basicstyle=\footnotesize,
261 stringstyle=\ttfamily,
262 flexiblecolumns=true, aboveskip=-0.9em, belowskip=0em, lineskip=0em}
266 "id":"4b3288b57e5c1b08a67147c495e54a68655fdab8",
267 "occured":1314829876295,
279 \caption{A billing event example}
284 \subsection{Implementation Experience}
286 One of the topics of debate while designing Aquarium was the choice of
287 programming platform to use. With all user facing systems in the Okeanos cloud
288 being developed in Python and the initial Aquarium designers being beginner
289 Scala users (but experts in Java), the choice certainly involved risk that
290 management was initially reluctant to take. However, by breaking down the
291 requirements and considering the various safeguards that the software would
292 need to employ in order to satisfy them, it became clear that a
293 typesafe language was a hard requirement. Of the platforms examined, the {\sc
294 jvm} had the richest collection of ready made components; the Akka library was
295 particularly enticing for its scalability and distribution possibilities it
298 The choice of Scala at the moment was a high risk/high gain bet for GRNet.
299 However, the development team's experience has been generally positive. Scala
300 as a language was an enabling factor; case classes permitted the expression of
301 data models, including the configuration {\sc dsl}, that could be easily be
302 serialized or read back from wire formats while also promoting immutability
303 through the use of the \texttt{copy()} constructor. The very active use of
304 immutability allowed us to write strict, yet simple and concise unit tests, as
305 the number of cases to be examined was generally low. The
306 \textsf{Maybe}\footnote{\textsf{Maybe} works like \textsf{Option}, but it has
307 an extra possible state (\textsf{Failed}), which allows exceptions to be
308 encapsulated in the return type of a function, and then retrieved and accounted
309 for in a pattern matching operation with no side effects. More at
310 \url{https://github.com/loverdos/Maybe}} monad, developed by the second author,
311 enabled side-effect free development of data processing functions, even in cases
312 where exceptions were the only way to go. Java interoperability was excellent,
313 while thin Scala wrappers around existing Java libraries enabled higher
314 productivity and use of Scala idioms in conjunction with Java code.
316 Despite the above, the experience was not as smooth as initially expected. The
317 most prominent problem we encountered was that of missing documentation. The
318 Akka library documentation, extensive as is, only scratches the surface.
319 Several other libraries we use, for example Spray for {\sc rest} handling, have
320 non-existent documentation. The Java platform, and .Net that followed, has
321 shown that thorough and precise documentation are key to adoption, and we
322 expected a similar quality level. Related is the problem of shared community
323 wisdom; as most developers know, a search for any programming problem will
324 reveal several straightforward Java or scripting language sources. The
325 situation with Scala is usually the opposite; the expressive power of the
326 language makes it the current language of choice for treating esoteric
327 functional programming concepts, while simple topics are often neglected. Scala
328 has several libraries of algebraic datatypes but no {\sc yaml} parser. As Scala
329 gains mainstream adoption, we hope that such problems will fade.
331 From a software engineering point of view, the current state of the project was
332 reached using about 6 person months of effort, 2 of which were devoted to
333 requirements elicitation, prototype building and familiarizing with the
334 language. The source code currently consists of 5.000 lines of executable
335 statements (including about 1.000 lines of tests), divided in about 10
336 packages. The system is built using both {\sc sbt} and Maven.
338 \section{Performance}
340 To evaluate the performance and scalability of Aquarium, we performed two
341 experiments: The first one is a micro-benchmark that measures the time required
342 for the basic processing operation performed by Aquarium, which is billing for
343 increasing number of messages. The second one demonstrates Aquarium's
344 scalability on a single node with respect to the number of users. In both
345 cases, Aquarium was run on a MacBookPro featuring a quad core 2.33{\sc g}hz
346 Intel i7 processor and 8{\sc gb} of {\sc ram}. We selected Rabbit{\sc mq} and
347 Mongo{\sc db} as the queue and database servers, both of which were run on a
348 virtualised 4 core with 4{\sc gb} {\sc ram} Debian Linux server. Both systems
349 were run using current versions at the time of benchmarking (2.7.1 for
350 Rabbit{\sc mq} and 2.6 for Mongo{\sc db}). The two systems were connected with
351 a full duplex 100Mbps connection. No particular optimization was performed on
352 either back-end system, nor to the {\sc jvm} that run Aquarium.
354 To simulate a realistic deployment, Aquarium was configured, using the policy
355 {\sc dsl} to handle billing events for 4 types of resources, using 3 overloaded
356 pricelists, 2 overloaded algorithms, all of which were combined to 10 different
357 agreements, which were randomly (uniformly) assigned to users. To drive the
358 benchmarks, we used a synthetic load generator that worked in two stages: it
359 first created a configurable number of users and then produced billing events
363 The measurements above were done on the first working version of the
364 Aquarium deployment. They present
366 \section{Related Work}
368 \section{Conclusions and Future Work}
369 In this paper, we presented Aquarium, a high-performance, generic billing
370 system, currently tuned for cloud applications. We presented the requirements
371 that underpinned its design, outlined the architectural decisions made
372 and analysed its implementation and performance.
374 Scala has been an enabling factor for the implementation of Aquarium, both
375 at the system prototyping phase and during actual development.
377 Aquarium is still under development, with a first stable version
378 being planned for early 2012.
380 Aquarium is available under an open source license at
381 \url{https://code.grnet.gr/projects/aquarium}.
383 \bibliographystyle{abbrvnat}
384 \bibliography{aquarium}