Showing posts with label Memcached. Show all posts
Showing posts with label Memcached. Show all posts

Jul 10, 2014

Scale Out Patterns for OpenStack (and other Cloud) based Systems

It is a common question these days how one should design their next system to support elastic and growth requirements in the cloud era.

As I got this specific query today, I would like to share with you my answer based on various materials I created in the last few years:


1. Avoid File Storage SPOF: Use AWS S3 or its equivalent open source OpenStack Swift as a central file server repository when needed

How to use OpenStack Swift for your business case

2. Avoid Data Store SPOF: Use clustered data store that recovers automatically w/o a DBA or an operator intervention. Fine examples are AWS MySQL RDS, MongoDB and Cassandra

MongoDB HA concepts

3. Avoid Static Servers: Leverage Autoscale features or customize it for your needs

How to implement your application logic to auto scale your app

4. Avoid Messing with Cache: Use a central sharded cache to avoid cache revocation and reduce data stores load using MongoDB, CouchBase or Redis.




5. Offload your servers sessions: in order to avoid users log off and lost transactions:

How to implement a session offloading using a central store

6. Avoid Service Downtime due to Servers Downtime: More issues that can be found in my extensive presentation:

 - Use DNS Load Balancing for Geo LB and DRP (Slide 10)
 - Use CDN to offload network traffic (Slides 16-19)
 - Perform Session Offloading by cookies or a central store (Slides 62-65)



Bottom Line
You can scale your app! just follow the right recommendations

Keep Performing,

Moshe Kaplan

Nov 5, 2013

Apache Session Persistancy Using MongoDB

Your app is booming, you need more web servers and you need to serve users and keep their user experience. When you had a single server you just used session for that, but now, How do you keep sessions across multiple web servers? 
Using a session stickiness load balancer is a good solution, but what happens when a web server needs a restart?

Session Off Loading
Many of you are familiar with the concept of session off loading. The common configuration for it is using Memcached to store the session object, so it is accessible from all web servers. However, this solution lacks the features of high availability by replication and persistence.

The Next Step: High Availablability
Offloading web servers sessions to MongoDB looks like a great solution: key-value store, lazy persistency and built in replication and auto master failover.

Step by Step Solution for LAMP Session Off Loading using MongoDB
  1. Install MongoDB (preferably in a replica set with at least 3 nodes)
  2. Install MongoDB driver for PHP: 
  3. Configure the php.ini: extension=mongo.so
  4. Download and integrate Apache session handler implementation using MongoDB.
  5. Configure your MongoDB setting in the module:
    1. Set the list of nodes in the connectionString setting: 'connectionString' => 'mongodb://SERVER1:27017, mongodb://SERVER2:27017',
    2. Do the same to the list of servers (see at the bottom of this post)
    3. Configure the cookie_domain (or just place a null string there to support all): 'cookie_domain' => ''
    4. Don't forget to enable replica set if you are using one: 'replicaSet' => true,
  6. Add the MongoSession.php to your server and require it: require_once('MongoSession.php');
  7. Replace the session_start() function with $session = new MongoSession();
And that's all. Now you can continue using the session objects as you used to create new great features:
if (!isset($_SESSION['views'])) $_SESSION['views'] = 0;
$_SESSION['views'] = $_SESSION['views'] + 1;
echo $_SESSION['views'];


Bottom Line
Smart work can tackle every scale issue you are facing off...

Keep Performing,

Appendix: 
'servers' => array(
array(
'host' => 'SERVER1',
'port' => Mongo::DEFAULT_PORT,
'username' => null,
'password' => null,
'persistent' => false
),
array(
'host' => 'SERVER2',
'port' => Mongo::DEFAULT_PORT,
'username' => null,
'password' => null,
'persistent' => false

)

Jul 3, 2010

Microsoft is Catching Up with the Internet Industry

Click on the title to view the full post, comments and add your own comment
For a long time I blame Microsoft for not really understanding the Internet and cloud Industry basic need: very large systems that can handle billions of daily transactions with a very low revenue per transaction. Now, after admitting its failure in the mobile industry (see Kin's death earlier this week), Microsoft finally reveals AppFabric after a very long time (I would like to thank my colleague Alon Biran for notifying me regarding it).



What is AppFabric?
The roots of AppFabric are located in the "Velocity" project that was developed in the SQL Server group (a year and a half ago I wrote a Knol about). This project was aimed to provide a key-value store (super hash) that will be used for two main objectives:
  1. Instant in memory storage data store (database replacement).
  2. Shared web session repository that will enable instant failure between web servers (the only Microsoft in house solution till now was using SQL Server as a shared repository)
After being in various CTP and beta versions for almost two years, AppFabric is finally out as part of the Windows platform rather than being a part of the SQL Server product. You may take a look at my colleague David Chappell's AppFabric white paper for complete set of features and scenarios.

Who are the Current Players?
The major players in the market these days are open source (Every each of the products has its own unique features, please feel free to comment on this post regarding it):
  1. Memcached: the #1 product in the market. Its roots are in 2003. It is an open source and Linux based product. Yet, Memcached has .Net client API as well as windows porting of the product itself.
  2. SharedCache: a native C# open source product that is a Memcached like.
  3. StateServer: commercial native windows product by ScaleOut Software.
  4. NCache Express: another commercial native windows product by Alachisoft.
Since AppFabric is provided for "free" as part of the Windows platform, the commercial native .Net products may be hurt from the Microsoft move. However, they may gain more users due to better publicity for this kind of solutions in the Microsoft development community,

Why Did It Take So Long?
It seems that Microsoft had a major cannibalization issue: If you provide a good key-value store then you may reduce the databases size and usage intensity. Thus, the number of high cost database licenses will be significant lower and the bottom line will be smaller. Oracle has the same problem with Coherence that is now part of the Fusion platform.
Taking this product into RTM is a true Microsoft understanding that if it really want to take a significant role in the Internet and cloud industry, it will have to sacrifice more than just few cents in its financial reports bottom line.

Bottom Line
These are very good news that Microsoft is finally provide a solution for a basic need of the Internet and cloud industry. However, while Microsoft was catching up with the Industry 2003 news, new requirements were raised including MapReduce, BigTable and other NoSQL advanced features. How much time will it take this time? Probably only Steve Ballmer has the answer.

Keep Performing,
Moshe Kaplan Follow MosheKaplan on Twitter

Feb 21, 2010

Lecture: Extract The Traffic from the DB

A few days ago I had a presentation in the AlphaGeeks meetup in Tel Aviv, presenting NoSQL, Memcached, CouchDB, Sharding and other buzzwords that help you extract the traffic from the database and boost your system performance. If you were not there, you can take a look at the presentation (English) or the recorded video (Hebrew).

The Presentation (English)
The Video (Hebrew)

Keep Performing,
Moshe Kaplan

Feb 16, 2010

Lectute: Memcached?, SimpleDB? NoSQL?: how the big boys handle massive query loads with non-SQL solutions


What: 5th AlphaGeeks Meetup
Where: Tushia 10, Tel Aviv, Israel
When: Wednesday, February 17, 2010, 18:30-21:30

Abstract
In the 1st AlphaGeeks meetup I presented the sharding concept and how can it help you meet the 1 billion events/day systems requirements. This time we'll talk about the new sexy and emerging technologies of No SQL and how can they help you meet these requirements.

Other lectures
- Amitay Dobo: On C# (4) and Mono.
Why C# is a kick ass language that can bridge traditional, functional and dynamic typing languages, and how it all works with the Mono project.
- Yuval Goldstein will conclude n international survey of 300 developers, about their jobs, their salaries, professionalism and overall happiness.

Dec 21, 2009

Lessons from Facebook:

FB maybe is not the best example for quality design (probably each of us is likely to have at least a single error message a day).

However, since it's the 2nd largest site in the world with contsant exponential growth, it's a good lesson to have. Most interesting that their tech is team is only about 250 people and 30K servers, pretty amazing.


Not long ago a Jeff Rothschild, the Vice President of Technology at Facebook gave a presentation in UC San Diego. You can find a detailed summary by Prof. Amin Vahdat, but I'll make several top comments that I found useful.
  1. FB Software development: mostly PHP (complied), but other languages are used as well.
  2. Common interface between services using an internal development that was turned to open source: Thirft. This interface enables easy connections between the different languages.
  3. Logging Framework that is not dependent on a central repository or its availability. FB is using Hadoop and well as Hive (that was developed there as well). The log size is growing at a 25TB a day.
  4. Operational Monitoring: Separated from the logging mechanism 
  5. LAN can be a bottleneck as well: expect for packet loss and packet drops in the LAN if you stress it too much.
  6. CDN: Facebook is using external CDN to images distribution.
  7. Dedicated file system named Haystack that combines simple storage along with cache directory: file system is accessed only once to get images from it, while directory structure is retrieved from the cache.
  8. Most data is served from Memcached. Database is used mostly for Persistency and data replication between sites (Memcached is being heated by the MySQL itself):
    1. Top challenge: keeping data consistent since Memcached can be messed easily (No search for keys is available).
    2. Mixing information including sizes and types is better - making sure that load on CPU, Memory and etc is distributed equally.
  9. Shared nothing - Keep your system independent - avoid a single bottleneck. Therefore, data is saved in a sharded MySQL from day 1. However, MySQL is used mostly for data persistency and not for conservative database usage pattern:
    1. No Joins in the MySQL
    2. Chosen due to good data consistency + Management Software
    3. 4K servers
    4. Data replication between sites is based on MySQL replication
    5. Memcached is being heated based on the MySQL Replication using a custom API
One last thing, if you are interested in Facebook financials, as well the storage machines (NetApp low end 3070), sizing, traffic, servers, storage procurement and data center costs, take a look at TechCrunch's Michael Arrington post.

Keep Performing,
Moshe Kaplan. Performance Expert.

Aug 18, 2009

Shared Cache: The Windows and .Net memcached

Hi again,

In memory databases and cache are must in any large scale system these days (you can ask Facebook architects regarding it). The Linux guys have memcached and there are many other products (with much more features of course) such as Gigaspaces XAP, Oracle Coherence and Scaleout. However, since Microsoft did not release yet the long expected Velocity product (will it ever be in production?), it seems there is a clear winner to the Windows environment: SharedCache. This product is some kind of a memcached porting to native managed .Net code and it is licensed under LGPL!.
SharedCached is already in production in several major sites including theport.com and it is fully documented. The product supports all major requirement from a caching product including:
  1. Partitioning - just like sharding, every server is taking care of part of the data, and the application server are talking with every cache server (unless of course you were wise enough to shard the application servers as well).
  2. Replicated Caching - keeping data in multiple instances, making sure data will always be available and lots of reads will be handled correctly.
I recommend downloading and testing this product and see if it fits your product/service needs,

Keep Performing,
Moshe Kaplan. RockeTier. The Performance Experts.

Dec 27, 2008

Online Games Industry Software Perfromance Boosting Case Study

Hi,

My colleague, Romi Kuntsman, refered me to Big Fish Games software performance boosting case study that was published not long ago by MySQL (now SUN).

MySQL is a significant player in the internet based systems niche which includes the online advertisement, SaaS, games and gaming and many others. The internet based systems were not long ago considered as not so complex systsms as the enterprise systems.
This assumption is not longer true. Internet based system and mostly the top players in the market are facing challenges that require non conservative solutions. Players such as Facebook, Google, Big Fish and CJ are facing the challenge to handle millions of events per second. This is significantly larger than most enterprise software and n-tier architectures based systems were designed to handle with.

Therefore, MySQL based systems that were considered to be a low-mid range systems, are facing these days the most challenging requirements of traffic and load.

MySQL just released a good example for that (I will present several other cases we dealt and dealing with in future posts): BigFishGames.com is a fast-growing website with over 25 million unique customer accounts and over 2.5 million visitors per month and it well financed (over $80M in the last financial round).

Due to their high growth rate (100%-220% per year in last few years accurding to TechCrunch replys), Big Fish faced performance issues, although they used over 40 different MySQL servers...

What did Big Fish do?

1. Database Profiling and Tuning:
Big Fish DBA team used MySQL Query Analyzer. This product provides a consolidated view of query activities and execution details, and it enables quick identification of poorly running queries and tackle the root causes directly in the SQL code. The DBA team caught a "bad" query running 400K times overnight which never showed up in query logs. Since the Query Analyzer uses a Service Agent listening to application queries and performances metrics, the MySQL servers can always be live and operational when being analyzed. There is no need to switch the servers back and forth between on-line and off-line, which eliminates unnecessary risks to server availability and reliability. Moreover, it enables the DBA team gain a real time statistics, rather than make the analysis based on test environment simulations.
After deploying the MySQL Query Analyzer, Big Fish Games tripled (X3) its database performance within three days.

2. In Memory Database and Distributed Cache Layer
Big Fish Games used Memcached as an in memory database soluton and distributed caching layer. By using Memcached, all online queries are performed in the application server memory, and no online queries are processed in the database. Once in a while the Memcached is being syncronized with the database. This solution improved the end user response time, system scalability and database performance.

3. High Performance Servers
Big Fish Games chosen Sun Fire x64 Servers (not so surprising since MySQL is owned by SUN) in three different architectures:
  • Sun Fire X2100: for applications which require lots of local disk space but less I/O or CPU speed
  • Sun Fire X4100: for applications which demand fast processors but don't need speedy local disk I/O
  • Sun Fire X4140: for applications where faster local disk I/O via RAID 10 and battery backed up write cache is essential (Memcached servers)
Right selection of the hardware enabled 20x in performance by merely replacing an X4100 server with an X4140 machine (and probably they paided for this selection)

I think that this case study is a great example of how a poor performance system can be boosted in factors of X100 and more. Moreover, these cases are not so rare. Many players in the market gain success, and require better performing systems at the fraction of the cost of legacy enterprise systems, without major redesigning their existing servers, and while keeping their current code base.

Best Regards,
Moshe,
RockeTier, the performance experts


ShareThis

Intense Debate Comments

Ratings and Recommendations