Showing posts with label Agile. Show all posts
Showing posts with label Agile. Show all posts

Tuesday, March 6, 2012

Logfile Aggregation and Analytics

One of the more important concerns of any organization that runs any kind of a public website is to be able to troubleshoot the applications and websites they operate. A typical web application runs in the popular architecture of one or more web servers, a load balancer, a cluster of application servers and a database layer. Additionally, there may be other enterprise-level elements like a message broker, a web services layer, an ESB etc.
A common feature of this architecture is that most of the components produce operational log files. Some are out-of-the-box logs, while others are configured and written by each application. Another common feature is the operations group/production support teams striving to support these applications by parsing these log files to troubleshoot issues reported by end users, monitoring apps and internal test teams.
A typical strategy (which really is a lack of strategy) is for a person or a team to download log files from different locations into a central location (or perhaps the logs are already on a specific log file server) and running grep/find/vi commands to search for incidents based on a given timestamp and/or an error message expected to appear in the log file. Many of you reading this will probably be empathizing with this (because you have done the same in the past) while simultaneously shaking your heads pitying those poor souls (because you feel their pain). What then follows as the next logical step is for someone in your team to finally take the initiative to write a utility to search through files and display some sort of a report on a web page with some limited search capabilities. At one point, you will get tired of maintaining this search app and start looking for alternatives in the world at-large. A client of ours was at this point when they asked us to come in and assist in defining their log management strategy. The following blog is a high-level review of three options and a more detailed review of one of those options.
We considered 3 options – not with any particular bias to excluding the others out there. It just so happened that we had some references to the ones we chose. We will first present a couple of commercial solutions that operate on different principles and being commercial, have all the relevant documentation and instructions on their websites.
  • Splunk
  • Loggly
  • Logstash + Graylog2

Splunk

Splunk (www.splunk.com) is a commercial product available for free to download and install. As of this writing, Splunk is free up to 500MB indexed per day. Visit their website for latest pricing and licensing details. Splunk’s feature set has evolved over the years and now offers a rich feature set with a RIA interface to manage your Splunk instance as well as perform analytics and queries. The UI features are impressive and let you administer the instance on the one hand and manage and run queries on your indexed data on the other. Splunk stores incoming data as compressed files. This data is then indexed and stored alongside the raw compressed data for fast and easy querying. Splunk ages your data in 4 levels – hot (current), warm (recent), cold (older than recent) and frozen (typically very old and candidate to be removed from the index). You can also customize maximum storage sizes and schedule to age data as well as chose to move frozen data to backup rather than delete it as Splunk would do by default.
Being a commercial product, you can expect support and an expert knowledgebase behind the product offerings. There are also, out-of-the-box recipes to quickly setup your instance and manage. Splunk can run in a clustered environment for high availability and performance. Additionally, there is a concept of Splunk Apps targeted at common products that are candidates for being monitored – Apache web servers, F5 devices, etc. The query language is reasonably intuitive and is custom but familiar if you have used an indexing engine before.
In my test, I saw the following storage compression ratios:
  • 14 MB - compressed to 1MB raw and 5.7 MB indexed
  • 55 MB - compressed to 5.7 MB raw and 15 MB indexed
Splunk offers a range of products in addition to Log Management – Network Management, Security and Compliance, IT Operations etc.

Loggly

Loggly (www.loggly.com) is another commercial product that offers cloud-based solution for Log management. There is no software to install and manage since it is all hosted by Loggly. You have to configure your applications/infrastructure to forward logs to Loggly’s server using one of their prescribed methods – TCP, HTTP, File upload etc. At the time of this writing, Loggly is free upto 200MB indexed data per day with a 7 day retention policy. The latter is in focus since you upload all data to Loggly and that becomes the basis for your queries and searches. Loggly offers a maximum period of 90 days retention after which you can use Loggly's archive feature to store them in your own S3 bucket. Loggly offers secure logging via TLS/HTTPs for all your data uploads. A rich web interface allows you to manage/administer your account and run queries. The query language is reasonably intuitive and is custom but familiar if you have used an indexing engine before.
When you sign up, you setup a sub-domain with loggly.com that becomes your log management site. You can login, and administer “your site” by creating users, input methods etc. Because there is no software to install, there is no collection agent out-of-the-box; you will need to proactively send data to Loggly using one of their prescribed input methods. Loggly lets you embed a javascript on your web application pages to send data to Loggly directly from the application layer.

Logstash + Graylog2

The third option is perhaps the most interesting yet. We look at two open source/free applications each of which is a complete solution in itself but ends up being better when combined to take advantage of their particular strengths.
Logstash (www.logstash.net) and Graylog2 (www.graylog2.org) are two products that play well together. Logstash can be your “backend” to monitor and collect data from different sources and Graylog2 can be the presentation layer with a richer UI than what Logstash provides.
Logstash is easy to install and run. It works based on a simple Input-Process-Output concept that is configured in a *.conf file. Input specifies which files/sources to read. Process section – formally called “Filter” – defines how the incoming data has to be massaged by applying regular expressions, rules etc. Finally, the output section will define where the data should end up. By default, the current version of logstash uses ElasticSearch engine to index data. You can either run an embedded version of ElasticSearch or point the output to an external instance, which could be a robust clustered instance. One of the options for output is to direct it to Graylog2 running as a separate process. You do this to take advantage of the richer UI features of Graylog2 which are clearly better than Logstash’s features.
Logstash has a variety of ways to read data – TCP, files, syslogs etc. If you choose to just point to your log files for Logstash to read and process, be mindful that this translates into “tail -0” on that file and hence data starts feeding into Logstash from the point in time at which your monitoring begins. Prior data is not read. There are ways to get around this easily but you have to do that manually. You can also run Logstash as a network of file readers (Logstash instances that only read and forward data) on different physical machines that are forwarding data to a single indexing Logstash instance which is responsible for processing data and indexing it for searching or forwarding data to Graylog2.
Graylog2 is another log management tool that Logstash interfaces with seamlessly. Logstash can output data as GELF (Graylog2 Extended Log Format) data to be consumed by Graylog2. For those who wish to aggregate and search application logs written by Java apps using log4j, there is an easy way to write GELF data using the gelf4j jar. You would define a gelf4j appender (https://github.com/pstehlik/gelf4j) in your log4j properties as shown below and voila, you have GELF data. GELF is a reader friendly format that captures log data in JSON format thus making is wonderfully easy to index and search. This makes your Logstash forwarders operate on GELF log data and your process layer should account for that. If you choose to only write using traditional log4j appenders, you would then use Logstash’s feature to convert to GELF before forwarding to Graylog2.

log4j.appender.GELF=com.pstehlik.groovy.gelf4j.appender.Gelf4JAppender
log4j.appender.GELF.graylogServerHost=my.gelf.host
log4j.appender.GELF.host=www13
log4j.appender.GELF.facility=local1
# use the GELF appender. set the level to INFO.
log4j.category.com.my.class.where.i.DoLogging=INFO, GELF

Putting it all together:
  • I chose to use a combination of Logstash and Graylog2. With this choice, you will also end up using MongoDB and ElasticSearch to support your log aggregation. I did not use a gelf4j appender.
  • I chose to monitor file in a location – in this case, where the log files were being written.
  • I chose to monitor logs from a Java App running on Tomcat v6 and Apache Web Server.
Install Mongo DB
Start the mongod shell and do the following:

mongo
use admin
db.addUser('admin', 'grayloguser-password')
db.auth('admin', 'grayloguser-password')
use graylog2
db.addUser('grayloguser', 'grayloguser-password')
db.auth('grayloguser', 'grayloguser-password')

Install ElasticSearch
Here, for my initial research, I have the option to use the embedded ElasticSearch that comes with the Logstash monolithic jar. I chose to use the embedded server and start it up with default settings, and so I did not need a separate install. ElasticSearch will automatically be started during Logstash startup at the default port.
Install Graylog2
After I followed the instructions and copied the sample configuration file, I had to edit the “/etc/graylog2.conf” file. *Note: You may need sudo access.
I updated the mongo db section to update the mongo db Graylog2 database, user id, password and host. I set the host to 127.0.0.1 instead of localhost on my MacBook Pro. The mongo db related setting should be the same as the parameters you used when you configured mongoDB in the “Install MongoDB” step above. Also, once you install the web interface, you will need to update the *.yml files in the “config” directory (specifically mongoid.yml for mongodb properties).
Download Logstash Monolithic Jar
Since I know the input to be files, I now need a way to read this input, transform it a bit to be really useful to me for search and display. Enter Logstash. I downloaded the monolithic jar file from www.logstash.net. (Note: While there, do make some time to watch the Logstash presentation by the author of Logstash.) Once the jar was downloaded, I then created a mylogstash.conf file in my text editor. You can read more about this on the Logstash website. My conf file looks like this:

input {
file {
type => "log4j-ml-55"
path => "/workarea/app40_CPU10_Logs/app40_CPU10_server8.log"
}
}
filter {
multiline {
type => "log4j-ml-55"
pattern => "^\[20"
negate => true
what => "previous"
}
mutate {
type => log4j-ml-55
replace => ["@source_host", "log4j-ml-55"]
}
}
output {
stdout {}
elasticsearch { embedded => true }
gelf {
facility => "logstash-gelf"
host => "127.0.0.1"
sender => "app40_CPU10_server8"
}
}

The filter is specific to the situation in my log file. Since I am collecting logs from a Java app, I need to make sure stack traces are treated as one incident/entry and the expression in the multiline filter pattern tells logstash that if a line does not start with “[20” character set, treat that line as part of the previous line and append it to that line. The mutate filter is interesting. Because my logfiles are from a centralized logging server, the remote host will point to that server. But what I really need as source host is the original host that generated the file and that is precisely what the mutate filter accomplishes.
Start it all up
Make sure MongoDB is up. If using a separate ElasticSearch instance, startup ElasticSearch. If using the embedded ElasticSearch, then start Logstash with the following command.
java -jar logstash-1.1.0beta8-monolithic.jar agent -f mylogstash.conf -- web --backend elasticsearch:///?local

Once Logstash is up and running, startup the Graylog2 server and Graylog2 web client in that order. Visit www.graylog2.org for details on how to start the server and web client.
You are all set. As your application and web logs get written, the pipeline of Logstash and Graylog2 will route it through to Graylog2 Web Interface and you should be able to run searches and analytics.
http://127.0.0.1:3000 is where Graylog2 web interface is available.

Conclusion

Log Monitoring is a critical tool in your troubleshooting arsenal. Based on the information you capture in your log files, it can also be a strategic tool for your company to perform analytics and searches, which in turn enables you to be a better customer-focused organization. Because the quality of your analytic depends on the input data, it may be a good idea to setup your monitoring using free/open-source software like Logstash+Graylog2 and then refine your application code to fine tune your logging input. This is not a feature that is functional on Day 1 of going live. You will have to spend time tuning your entire setup to arrive at optimal input data and output analytics.
Some things to consider:
  • Treat this as a project with a definite charter and expected outcomes
  • Involve business and IT ops to define the analytics output desired
  • Involve your development teams to ensure that the data captured in the log files will support the analytics requirements
  • Ensure buy-in from teams for continuous improvements
  • Prototype with free/open-source tools initially.
This will definitely include involving your business and IT stakeholders to define requirements upfront for analytics. Also, your development teams must dedicate some time to design and implement an effective logging technique to capture the required data in the required format. With a little effort upfront and commitment to continuous improvement, you will get to the Promised Land of log aggregation and analytics.



Tuesday, February 15, 2011

Agile Adoption - How to encourage a client or employer to adopt Agile

As we celebrate the 10 year anniversary of the Agile Manifesto, it is clear that Agile has become one of the most important concepts in Software Engineering in these last 10 years. It has been rapidly accepted, adopted and butchered in every possible way. As with anything that rapidly accepted, there have been a number (perhaps a majority) of the "adopters" who claim to be Agile or Agile-minded but are clearly mistaken in their understanding of Agile.

This is a link to an article by Martin Fowler and Jim Highsmith following their signing of the Agile Manifesto: http://www.drdobbs.com/184414755

As I have moved between jobs and also been in consulting at client sites, I have noticed the increased awareness of the Agile buzzword. As much awareness I see, I see the same amount of misinformation.

I have seen two categories:
  • The old crusty PMI/mainframe guys who show intense mistrust of Agile. They view our enthusiastic support with the same amused attitude that we show to teenagers who love boy bands - "these kids and their stupid toys" they seem to be saying.
  • The new generation developers/project managers/business analysts who are supportive but confused. To them, Agile is periodic delivery of software and a daily status meeting. Managers especially like this. They think - "Boy! I am going to get software delivered every 2 weeks and I can demand what's going on everyday! How cool!". Clearly, they fail to see their responsibility in ensuring that this happens.
I love this quote from a colleague regarding a client - "You can't convince them they are not Agile!".

So, in this blog, I will attempt to articulate the different stages of Agile adoption and the roles/attitudes of personnel I have encountered in my experience. I will use the following roles in my diagrams and explanations.

Agile Champion: The true Agile expert and champion who is attempting to bring about true change.
Analyst/Project Manager: The PMI school adherents who think they know Agile.
Developer: Junior to Mid-level developers who are amenable to adopt Agile but don't know how.
Senior/Experienced Developer: The crusty veteran/mainframe guys.
Senior Management: VP, Director, C-suite officers

Stage I: Pre-Agile



In this stage, the organization is cruising (or not!) along with waterfall and delivering projects with > 6 month timelines for even relatively small efforts. Analyst/Project Manager is aware of Agile having heard it in some training or the other. Developer is also familiar with Agile. Senior Management just wants things done now and without delays.
The diagram shows relative levels of support for Agile in this stage. The Agile Champion is the one with the most enthusiasm and the rest of the company is sort of indifferent to Agile.

Moving to the next stage, the Agile champion is faced with some tough questions. The choices are coerce, enforce, collaborate and to co-opt.

Does he/she approach management to enforce or Project Manager to coerce or Developer to collaborate and to co-opt?

The first instinct is to go to management and in a grand presentation, show-off Agile, bring in an external/recognized export and get them to OK the adoption of Agile. In my experience, this is not only useless but also a sure way to fail. The moment, Senior Management thinks something is going to on to improve delivery, they want it now and are not willing to play their part because they are too busy.

Coercion will not help either because this will quite often incubate a mild to major rebellion among Developers and Senior Developers just because they are coerced and there will also be perceived performance pressures.

So, the best choice is to collaborate and co-opt.

Stage II: Early Adoption



So the Agile champion approaches the Developers first and begins to show them the benefits of Agile thinking. This involves in my opinion Test Driven Development, just enough design and continuous integration. Trying to proselytize without concrete deliverables will only confuse the concept further. So, the collaborate and co-opt phase involves a lot of doing and showing while encouraging learning and practice. Developer ( and usually not the Senior Developer) is willing to try and learn. In most cases, the tools and software are on the Agile champion's personal computer.
As the Agile champion demonstrates TDD and benefits of user scenarios, the Developer slowly begins to voluntarily perform some of the tasks and experience the excitement and joy of having tests to cover their regression testing. Refactoring exercises naturally enhance their just enough design skills and they get more comfortable with talking to the customer or product owner (Analyst).
As you can see, the diagram shows the Early Adoption stage.

What next?

Stage III: Growing Influence


In many cases, if the previous stage was reasonably successful, the Agile adoption has typically gathered mass and moving downhill. This is also the most critical stage in this model. Having established the tools and techniques, it is time to begin driving home some of the concepts behind the actions so far. In most cases, the tools and software are on the team's development server and resources are being shared.
If the Developer is doing his/her job, then he/she is speaking up in requirements meetings asking about developing user scenarios and quick milestones. The Analyst/Project Manager sees that the developers are more into asking the right questions and are forced to find answers and they begin to experience the joy of always talking to the customer and getting feedback and reducing surprises when software is delivered.
So, you can see the growing influence of Agile thinking among Developer and Analyst/Project Manager roles. The customer loves being involved with the developer in refining and validating requirements often. This is the stage when the Agile champion has to formalize some sort of education/training and encourage discussion and self-learning among these personnel. It is important to answer: Why TDD?, Why just enough design? Why refactoring? What is Technical Debt and when to repay it?

This is reflected in the Growing Influence stage diagram. The Agile champion duties are now spread among Developer, Agile Champion and Analyst/Project Manager. It is critical to show positive results in this phase.
More often than not, by the end of this phase the Senior Developer is participating in the Agile adoption out of little choice in the matter. This role has to be managed carefully as they often have the ear of Senior Management and can cause adverse impact to Agile adoption.

One note of caution: At this stage, since Agile is not your official model and many companies are bound by scheduled releases, this may not be true Agile continuous delivery. But, if you have managed to deliver the final product on the scheduled release date but with high quality and high customer confidence of the final product, you have achieved Agile in my opinion. We all cannot be nor indeed need to be Facebook or Twitter or Google and deliver features to production every two weeks. THe goal of Agile is not to achieve this model. Rather, it is to achieve high software quality while delivering as close to customer expectations.

Stage IV: Active Practice


In this stage, Senior Management has become aware of the growing influence of Agile and have seen results. This is the the time to break out the power points and bring in the external expert if necessary to present to Senior Management that Agile is indeed viable and demonstrate your successes so far. If Senior Management sees most of the team willing and active participants, they rarely have incentive to shut it down.
As I said earlier, they usually care about delivering value to the organization's customers as expected.
The Agile Champion's role is reduced to be more of an evangelist in the company and interfacing with Senior Management to promote official adoption.



Stage V: Evangelical



This stage is achieved when the company officially recognizes Agile processes to software development and delivery.Tools and Technologies revolve around augmenting Agile and there is support to buy requisite tools. Potential new hires are evaluated during interviews according to their experience with Agile or willingness to be in that environment. All stakeholders speak and think in terms of Agile processes and are willing to put this at the top of the priority while thinking about delivering value to their customers.
The Agile Champion's role is greatly reduced to be more of an evangelist in the company and externally as the case may be. This role merges into Senior Technical Leadership role either as Senior Developer or Architect depending upon the company's policies.


Thursday, January 27, 2011

What's on TV?

I don't watch TV. That's not to say, I don't watch TV. Rather, I don't watch TV in the sense of following a show, following a schedule or remembering show times (unless you count Kids' cartoons on PBS, which I watch with my kids!). I watch my share of temporal sports events like Dallas Cowboys football, College Football and Basketball but beyond that, what ever is on for a few minutes between 6 and 7 in the evenings as we sit for a while after dinner. A big reason also, I must admit, are the kids. They keep me busy and I don't want to watch any crap when they are around the living area anyway.

I don't get TV shows. I am not sure if I am too cynical or the shows are that bad. A lot of people I like and admire watch shows such as "Jersey Shore", "Survivor" and other dramas too. I guess they watch it with a dose of inbuilt reality and detachment that they don't get carried away. They enjoy those shows while watching it and can talk about it later but still be grounded. Me, I watch it for a few minutes and go, "Man! That's a load of crap!" and turn it off.

I guess I should develop a sense of detachment and healthy appreciation for stuff around me and yet be not caught up in it.

What is CQRS? My experience with implementing it. Part 1

A short post about CQRS and my experience with it.

One of the more interesting programming/design patterns as I was learning Java way back was the command pattern. Sure, this pattern has been around a long time and has been well defined and discussed. But the first time I implemented it was through Java.

The pattern itself is conceptually easy. There is a command handler that handles any command submitted to it. The command typically implements an interface that the handler executes. With this flexibility, one can introduce pre- and post- execution methods, execute-around method similar to an Aspect etc.

While this pattern was primarily used as one component of the application's architecture, it was almost never the basis of the architecture of any project I worked on until recently. I had the opportunity to be able to implement a CQRS style framework for a greenfield project.

What is CQRS?
Stands for Command Query Responsibility Separation. The concept as the name (sort of) explains is to separate out concerns where a system is 'comman'ed to do something versus a system is queried for something. Wait! Isn't that pretty much obvious and a given in any system. When I command system to save some data, I use a dufferent syntax and when I query it, I use a different syntax. Well, not so fast. This is not about syntax. Rather it is about the semantics of how one saves and queries, the architecture that supports these operations and how they should be separated for better performance and maintainability.

So, let's look at a typical architecture of a web application. We have the three tiers (perhaps more but let's keep it simple here).

The UI/Client layer interacts with the user and asks the business layer to respond to the user's actions - to save data, to show data, to perform a calculation and show results, to collect data from separate sources and show as a dashboard/portal etc.

The business layer accepts request, acts upon it by either persisting, querying, calculating and returns result back to UI/Client.
A few issues I have with this approach:
1. Traditionally, the business layer providers interface for each of these actions. For instance, there is usually a handler (action/controller etc) for Create, one for Update, one for Query and so on. This makes the architecture open to modifications for any new request in an unnecessary way.
2. This also makes the UI very CRUD based. If one wants to update say a user profile to change address, one opens the entire profile screen with all editable fields and updates the addressline and submits. Lost in this update (unless there is a lot of scripting or code involved) is the fact that the user only wanted to update address as opposed to the entire record.
3. Of course, some architectures combine this into one action that performs the appropriate task based on a parameter in the incoming request. But this is not preferred since the one handler can get large and messy. Needless to say, a simple requirement change makes it susceptible to dangerous side effects.
4. An architecture such as this typically serves one client - a UI, or a web service and leads to code duplication.
5. The ORM becomes the source of persistence as well as query and anyone who has dealt with complex database structures and/or large datasets to be queries will know that the ORM typically can be optimized to persist or read but not both especially if the reads bring back large datasets coupled with complex object maps.

How does CQRS help overcome these issues?
  • CQRS separates the read and write concerns while opening a whole new architectural avenue to implement apps. Basically, every operation becomes a command and a command handler will inspect the command to determine the action to take.
  • This makes the command and command handler a standard interface of the application to the entire client base. UI, Web Services, JMS Messages etc can all now interact with the business layer in a standard interface.
  • The command can implement business logic and hence this will be reused and standardized across the application. Required fields, sizes, formats etc can be validated.
  • Command handler can do pre- /post- processing to send notifications, audits, initiate events based on data updates, deletes etc.
  • CQRS allows creating task-based UI where a specific task can be targeted. In the earlier example of a user updating address, if the UI allowed a user to change just one field, and this operation becomes a command called update zip code, then the command handler knows exactly what changes, audit trail is granular as well. Any business logic that depends on zip code can be implemented cleanly without a gazillion lines of code to determine whether business logic changed and then take action.
  • In this case, the command carries all that is needed to be done.and that command is audited. If partner system need to know that zip code changed, an event/message can be sent to interested parties to listen on it.
An extension of this pattern is to complement this with event sourcing. A command can publish an event out to a queue/topic as it updates the OLTP database. This can be a distributed transaction to write to a queue and database. A queue listener can then push this out to the Datamart and/or other interested applications in the enterprise.
One can even implement the command itself as an event that is consumed by the handler and perhaps updates the OLTP database and the datamart.

Saturday, February 27, 2010

Studying for another mid term...

...Strategic Management. Wonderful topic. I only wish more real-world managers have to go through this before getting the job rather than getting the job just because they are around for years and years.

Thursday, July 23, 2009

Agile Expertise and the Dreyfus Models

My journey through the Dreyfus model was more atypical than the model's definition. I am not sure if the Dreyfus model really works as a road map to gain Agile expertise or teach Agile processes.

Dreyfus theorized the following stages:
1. Novice
2. Advanced beginner
3. Competent
4. Proficient
5. Expert

The way I look at it, Agile is not for the faint-hearted and certainly not for a novice. By its very nature, Agile is more of a mind-set than a set of proscribed practices and steps. To develop the mind-set to operate in Agile mode, one has to have gone down the path of non-Agile to appreciate the advantages of Agile. Otherwise, one will be stuck thinking Agile is a process and certain "steps" are required. So, by definition, the person is an experienced developer and may even have practiced Agile in some fashion or another and liked and longs to do it again.

Agile as a principle is more a life lesson than a software development principle. Most people I know when initiated into an Agile development environment feel more at home than not. The objections they raise are mostly due to external factors - "but they need a requirements document", "my boss needs a technical design document" and the best of all "how long will it take EXACTLY?". They do wish to build incrementally, test and preview incrementally and follow the feedback loop because they have been burned in the past too many times.

Most people in real life would like to try something before they buy - at the store, a friend's place etc. So, when "beginning" Agile development, it really is not a beginning, rather starting at the Advanced Beginner stage for a short time and moving on quickly to competency.

I have had junior developers, college grads on my Agile teams and even they usually are not new to Agile. For instance, Scrum is something they grok soon enough. Incremental delivery and build is also not a big deal. So, by me definition, they are not novices.

Thoughts?


Another day in the books

Kids are asleep and I have time to get back to some studying. I am now writing a case study paper for my MBA class. It is an interesting subject - International Strategic Management.

This week we studied MNCs and their approach to a market - beneficial, exploitative, transactional and deeply involved. Case study involves a pharma company that developed a treatment for a rare disease and the marketing model adopted was to basically give the product away free to patients. How interesting and original! They made their money off of reimbursements they got from insurance companies, governments etc who were involved in patient care. Of course it helped that it was a rare disease and that they were not treating millions of patients and giving away tons of free medicine.