SlideShare a Scribd company logo
ROMA
        User-Customizable NoSQL
            Database in Ruby



Rakuten, Inc., Rakuten Institute of Technology | Masaya Mori
                                                               1
Introduction



• 森 正弥 (もり まさや)
           まさや)
• 楽天株式会社 執行役員
• 楽天技術研究所 所長
• 職掌
                            Masaya Mori
  – 開発部署のマネジメント           Twitter: @emasha
  – 研究開発の推進・統括




                                             2
Rakuten Institute of Technology

                  Strategic R&D organization for Rakuten group

                     Concept                                   Tokyo & NY

                 More Than Web
 - Your great reality through emerging technologies -

                      Mission
Turning emerging and growing new technology seeds
        into new business/service opportunities
to enrich the internet life (& real life) all over the world

                                                                            3
Global R&D has begun.


30 in Tokyo & 10 in NY


Tokyo                 New York




                                 4
Issues and our R&D area



 The internet has been growing to be diverse,
 huge, complicated and high-valued.
       • On basis of that, we progress three
         following R&D area to provide solution in
         the near future.

       Power                Intelligence              Reality

・Distributed computing      ・Knowledge mining    ・Multimedia Processing
・High performance computing ・NLP / Recommender   ・Ubiquitous / next UI

                                                                      5
Unite, Contribution to Academia
Data Ecosystem                                 R&D symposium




                                                               Post / publish
  Promote academic researchers
  to exploit Rakuten’s web public data


                 Expected results

・share R&D with external researchers
・increase data & service awareness of people
                                                                         6
Agenda


• Background

• Features of ROMA

• Overall architecture of ROMA

• Plug-in architecture and its domain specific language

• Conclusion




                                                          7
Internet Service


• User-driven service
   – Release is just a beginning.
   – As per user’s request, always Improve, always Advance.


• Software runs on Sever side
   – Can change any time
   – Big gap between package software and server side application

• Flexibility, Speed > Perfect
   – Lightweight Language
       • Ex. Ruby, Perl, Python, etc.
   – A.R.C.
   – Schema-less
       • CouchDB, MongoDB
   – Virtualization, Cloud

                                                                    8
Internet technology


• Advantage of Open Source
   – Risk of vendor rock-on
   – Easy to start
   – Collective Inteligence, Collective Development

• Simple & Loose
   – HTTP
   – REST + JSON > SOAP or EBXML or EJB
   – MySQL, memcached

• Scalability
   –   Load balancing
   –   Cache
   –   Distributed Cache
   –   Disk I/O is always too slow

                                                      9
High Performance

• Importance of good performance
   – Amazon : 0.1s of latency -> down 1% sales
   – Google : 0.5s extra rending time -> drop 20% traffic
   – Generally, 1sec delay means ..
        • Down 11% Page Views
        • Down 7% Conversions
        • Down 16% Customer Satisfaction
   – Lost tens of millions yen by 5 minutes service down

• To achieve high performance website
   –   Reduce size of HTML, Javascript
   –   Local Cache, Ajax
   –   On memory solution with consistency
   –   SSD > HDD
   –   Less latency
   –   GPGPU
                                                            10
High availability

• 24/7
   – Downtime = Lose profit

• Redundancy
   –   Power
   –   Network
   –   Load balancer
   –   BGP
   –   RAID
   –   Replication and Backup
   –   Data Center
   –   Operator

• BCP for disaster
   – Big earchquake

                                            11
Big Data, the direction

• New value from big data
   – Data mining
   – Suggestion, Recommendation
   – Personalization

• Technology to deal with big data
   –   Cassandra
   –   Hadoop
   –   Lucene + Solr Cloud
   –   It’s referred to as NoSQL roughly.
        • Processing ex. MapReduce
        • Storing ex. KVS

• Search
   – Answer within 0.1s from over 70 million items

• BI
   – Can provide analyzed data to sales & marketing
   – Also provide tools reflecting knowledge of statics
                                                          12
Storing: NoSQL databases


• Needs for NoSQL databases are on the increase in
  order to easily store surging data

• Basic features of several NoSQL databases are
   –   High scalability
   –   High availability
   –   High throughput
   –   Other features vary by databases


• ROMA
   – Started development with Matz in 2007
   – Open sourced in Oct. 2009
        • See http://github.com/roma/roma/




                                                     13
ROMA Usage in Rakuten


• ROMA is used in various Rakuten services
   – ROMA runs on dozens of servers
   – Various types of data are stored
      • E.g. session data, personal page view history, etc


• Rakuten, Inc.
   – It provides many e-commerce platforms
      • E.g. Rakuten Ichiba, Rakuten Travel, Rakuten Books, etc
   – Rakuten has over 70 millions of users




                                                                  14
Application-Specific Needs

• Many specific needs from application-side
   – These specific needs come from actual service development
     sites

• For example, users say
   – “How can we store structured data?”
      • Not value, but…. Map? List?
   – “How can we easily process stored data on DWH or Hadoop?”
   – “How can we delete null character that was stored somewhere
     by error?”
   – “How can we delete duplicate data that were accidentally
     stored somewhere, maybe by bugs of app?”

• We want to respond to all of these needs
   – We are trying to solve these problems, one by one.
   – Thereby, we hope we focus on what really matter on site.
                                                                   15
Case Study: List Operation in Rakuten Travel


• “How can we easily access list data stored in ROMA?”
   – Request from Rakuten Travel to apply page view history
     using ROMA
   – Page view history function is useful function for users




                                                               16
Case Study: List Operation in Rakuten Travel

• The application stores list data for users in database
     – Key: user ID, Value: a list of pages that the user viewed

• In such case as memcached,
  to delete list data stored in NoSQL database, application…
     1.   Gets binary data of specified key
     2.   Deserializes it as list data
     3.   delete the list data according to user requirement
     4.   Serializes the list data to binary data
     5.   Set it to database
                                        ① get binary data

“delete 2nd elm into list” req

                                            ⑤ put binary data


                                 ② deserialize binary as list data   Memcached cluster
                                 ③ delete 2nd elm into list
                                 ④ serialize list data to binary                         17
ROMA


• User-customizable NoSQL database in Ruby

• Features
   –   Key-value model
   –   High scalability
   –   High availability
   –   Fault-tolerance
   –   Better throughput
   –   And…

• To meet application-specific needs, ROMA provides
   – Plug-in architecture
   – Domain specific language (DSL) for Plug-in


• ROMA enables meeting the above need in Rakuten Travel

                                                          18
Overall Architecture


• ROMA integrates several well-known techniques to achieve
  scalability, availability and fault-tolerance
   – For example, consistent hashing, virtual nodes, chain
     replication-like mechanism, lamport clocks, etc


• ROMA node consists of 4 modules
   – Network IO module: Receiving data from clients and other
     ROMA nodes
   – Command exec module: Creating and executing commands
   – Routing module: Maintaining ring information
   – Storage module: Storing data

                        Network IO module

              Command Execution
                                    Routing module
                  module

                         Storage module
                                                                19
Data Partitioning

• Consistent hashing and virtual nodes
   – ROMA consists of several nodes that run on servers
   – Many virtual nodes are allocated on 1-dimensional hash space
     of 32-bits


• Each virtual node has a 32-bits ID
   – To determine which ROMA node to store key in.
   – SHA-1 hash

   E.g. ROMA consists of three nodes



                                                     ROMA




                                                                    20
Data Accessing


• In getting value of specified key from ROMA
   1. User accesses to ROMA nodes
   2. The node determines others that are responsible for value of
      specified key
   3. The node gets the value from the other node
   4. The node returns it to user
                                                   ①




  E.g. ROMA consists of three nodes                           ②


                                                       ROMA




                                                                     21
Sharing routing table

• Each node maintains and periodically shares routing table
  with others
   – Routing tables: range of hashs, machines, port
   – If several versions of routing table exist, node updates the
     latest version.
   – Lamport clocks and Merkle hash tree

• ROMA node multicasts with others to share routing tables
   – We use multicast though being aware of scalability.
   – Current version of ROMA doesn’t use gossip-based protocol.
  E.g. ROMA consists of three nodes




                                                     ROMA




                          Sharing ring information
                                                                    22
Client has cache of routing table

• ROMA client enables direct accessing to data
   – Client has a cache of routing table.
   – It checks to see if routing table is updated or not every 3 sec.


• In getting value of specified key, ROMA client
   1. Determines nodes according to cache
   2. Gets the value from the node directly



    E.g. ROMA consists of three nodes




                                                          ROMA




                                                                        23
Data Replication


• Automatic data replication
   – Client waits until data replication finishes successfully.
   – If data replication failed, the data is push to asynchronous
     queue in node, which it will retry replication.
   – Eventual consistency

• Each data is replicated at N nodes
   – N: this parameter is configured in advance
   E.g. ROMA consists of three nodes


                                                           ROMA




                                                                    24
Message Protocol


• Extended Memcached protocol over TCP
   – Used between clients and ROMA nodes


• Memcached client libraries are also available.
   – Without distribution concern
        • User can access any node and ROMA forwards it later.
   – Users can use telnet.
                                         $ telnet localhost 11211
                                         Trying 127.0.0.1...
                                         Connected to localhost.
                                         Escapecharacter is ‘^]’.

                                         set foo 0 0 3
                                         bar
  User can set/get data in ROMA          STORED
  with telnet like memcached
                                         get foo
                                         VALUE foo 0 3
                                         bar
                                         END
                                                                    25
Failure Detection


• Heartbeat detection
    – Each node multicasts periodic heartbeat with others
    – Heartbeat is flooded every 1 sec.


• If heartbeat is missed continuously, the node is
  declared as failed
    – Failover
    – Removal of the node

E.g. ROMA consists of three nodes


                                                  ROMA




                        Sending heartbeat

                                                            26
Plug-in Architecture


• Plug-ins allow users to extend behavior of ROMA

• For example,
   – Command plug-ins enable to change behavior of command
     module
   – Users can append user-defined commands to ROMA
   – Current version provides plug-ins for command module only
       • Plug-ins for other modules coming soon
       • For example, storage-plug-in.



                                Network IO module

                     Command Execution
 Command Plug-ins                           Routing module
                         module

                                 Storage module

                                                                 27
Case Study: Commands for List Operations

     • ROMA allows defining commands for list operations as
       plug-ins
                – Users can atomically access list data stored in ROMA as
                  value
                                            ① get binary data

“delete 2nd elm into list” req

                                                ⑤ put binary data


                                     ② de-serialize binary data
                                     ③ delete 2nd elm into list
                                                                           Memcached cluster
                                     ④ serialize list data



                                           delete 2nd elm into list data
“delete   2nd   elm into list” req




                                                                                 ROMA          28
Case Study: Commands for List Operations
                           # alist_insert <key> <index> <bytes> [forward]¥r¥n
                           # <data block>¥r¥n
                           #
                           # (STORED|NOT_STORED|SERVER_ERROR <error message>)¥r¥n
                           def ev_alist_insert(s)
                             hname, k, d, vn, nodes = calc_hash(s[1])
                             data = read_bytes(s[3].to_i); read_bytes(2)
                             return forward2(nodes[0], s, data) if nodes[0] != @nid
 Method declaration          ddata = @storages[hname].get(vn, k, d)
 for list command            v = [[], []] unless ddata
 named “alist_insert
           alist_insert”
           alist_insert      v = Marshal.load(ddata) if ddata
                             v[0].insert(s[2].to_i, data)
                             v[1].insert(s[2].to_i, Time.now.to_i)
                             expt = 0x7fffffff
                             ret = @storages[hname].set(vn, k, d, expt, Marshal.dump(v))
                             @stats.write_count += 1
As for lines, like this.     if ret
                               redundant(nodes[1..-1], hname, k, d, ret[2], expt, ret[4])
User can use also              send_data("STORED¥r¥n")
Telnet.                      end
                             send_data("NOT_STORED¥r¥n") unless ret
                           end                                                          29
Command Plug-in Mechanism


   • Command exec module
       – Loads plug-in and registers plug-in method at startup
           • Plug-in method has method name starting with ev_
           • For example, ev_alist_insert is plug-in method
           • Ruby allows adding new methods to classes dynamically


       – In calling plug-in method
           1.   Receives data from network IO module and creates new command
           2.   Finds registered plug-in method responding to the command
           3.   Calls plug-in method
           •    Uses send method provided by Ruby.

                                Network IO module

                      Command Execution
Command Plug-ins                            Routing module
                          module

                                  Storage module

                                                                               30
DSL for Command Plug-in

• DSL enables users to simply declare commands
   – Without distribution concern (data replication, data
     partitioning)
   – def_write_command_with_key_value
      • Allows easily defining commands for storing structured data
        in ROMA
• For example,
   – User can declare a alist_insert command with DSL
     # alist_insert <key> <index> <bytes> [forward]¥r¥n
     # <data block>¥r¥n
     #
     # (STORED|NOT_STORED|SERVER_ERROR <error message>)¥r¥n
     def_write_command_with_key_value :alist_insert, 3 do |ctx|
       v = [[], []]
       v = Marshal.load(ctx.stored.value) if ctx.stored
       v[0].insert(ctx.argv[2].to_i, ctx.params.value
       v[1].insert(ctx.argv[2].to_i, Time.now.to_i)
       expt = 0x7fffffff
       [0, expt, Marshal.dump(v), :write, 'STORED']
     end                                                              31
Commands for Map Operations with DSL


• Another example: User can declare map_set command
  with DSL
   – User can store map data in ROMA as value of specified key
      # map_set <key> <mapkey> <flags> <expt> <bytes>¥r¥n
      # <data block>¥r¥n
      #
      # (STORED|NOT_STORED|SERVER_ERROR <error message>)¥r¥n
      def_write_command_with_key_value :map_set, 5 do |ctx|
        v = {}
        v = Marshal.load(ctx.stored.value) if ctx.stored
        v[ctx.argv[2]] = ctx.params.value
        expt = ctx.argv[4].to_i
        if expt == 0
          expt = 0x7fffffff
        elsif expt < 2592000
          expt += Time.now.to_i
        end
        [0, expt, Marshal.dump(v), :write, 'STORED']
      end
                                                                 32
DSL Mechanism


•   def_write_command_with_key_value is declared as method in Ruby

def def_write_command_with_key_value(cmd, idx_of_val_len, forward = :one_line, &block)
  define_method "ev_#{cmd}" do |s|
    params = CommandParams.new
    params.key, params.hash_name = s[1].split("¥e")
    params.digest = Digest::SHA1.hexdigest(params.key).hex % @rttable.hbits
    params.vn = @rttable.get_vnode_id(params.digest)
    params.nodes = @rttable.search_nodes_for_write(params.vn)
    params.value = read_bytes(s[idx_of_val_len].to_i)
    read_bytes(2)
    stored = StoredData.new
    stored.vn, stored.last, stored.clk, stored.expt, stored.value =
        @storages[params.hash_name].get_raw(params.vn, params.key, params.digest)
    stored = nil if stored.vn == nil || Time.now.to_i > stored.expt
    ctx = CommandContext.new(s, params, stored)
    ret = instance_exec(ctx, &block)
    if ret
      redundant(ctx.params.nodes[1..-1], ctx.params.hash_name,
          ctx.params.key, ctx.params.digest, ret[2], expt, ret[4])
      send_data("#{msg}¥r¥n")
    end
    send_data("NOT_#{msg}¥r¥n") unless ret
end
                                                                                         33
Conclusion


• Background
   – Spread of NoSQL databases
   – application-specific needs


• Features of ROMA
   – To respond to specific needs, ROMA provides user-customizable
     interfaces
   – Plug-in architecture and its domain specific language


• Overall architecture of ROMA
   – It integrates several well-known techniques
      • Consistent hashing, chain replication-like mechanism, lamport
        clocks, etc


• Plug-in architecture and DSL
   – Plug-ins allow enhancing behavior of ROMA easily
                                                                        34
Thank you for kindly attention




                                 35

More Related Content

What's hot (20)

PDF
Storage Infrastructure Behind Facebook Messages
yarapavan
 
PDF
Introduction to map reduce
TrendProgContest13
 
PDF
Realtime Apache Hadoop at Facebook
parallellabs
 
PPTX
Hadoop World 2011: Mike Olson Keynote Presentation
Cloudera, Inc.
 
PPTX
Oct 2012 HUG: Hadoop .Next (0.23) - Customer Impact and Deployment
Yahoo Developer Network
 
PDF
Hadoop Successes and Failures to Drive Deployment Evolution
Benoit Perroud
 
PDF
Hadoop World 2011: The Hadoop Stack - Then, Now and in the Future - Eli Colli...
Cloudera, Inc.
 
PDF
Introduction to hadoop and hdfs
TrendProgContest13
 
PDF
A Survey of Petabyte Scale Databases and Storage Systems Deployed at Facebook
BigDataCloud
 
PDF
Facebook keynote-nicolas-qcon
Yiwei Ma
 
PPTX
Hadoop Summit 2012 | HBase Consistency and Performance Improvements
Cloudera, Inc.
 
ODP
Hadoop Ecosystem Overview
Gerrit van Vuuren
 
PDF
Apache Spark Overview part1 (20161107)
Steve Min
 
PDF
Hadoop 101
EMC
 
PDF
Hadoop Distributed File System Reliability and Durability at Facebook
DataWorks Summit
 
PDF
Common and unique use cases for Apache Hadoop
Brock Noland
 
PPTX
Drill njhug -19 feb2013
MapR Technologies
 
DOCX
Hadoop Tutorial for Beginners
business Corporate
 
PDF
Apachecon Euro 2012: Elastic, Multi-tenant Hadoop on Demand
Richard McDougall
 
PPTX
Hadoop configuration & performance tuning
Vitthal Gogate
 
Storage Infrastructure Behind Facebook Messages
yarapavan
 
Introduction to map reduce
TrendProgContest13
 
Realtime Apache Hadoop at Facebook
parallellabs
 
Hadoop World 2011: Mike Olson Keynote Presentation
Cloudera, Inc.
 
Oct 2012 HUG: Hadoop .Next (0.23) - Customer Impact and Deployment
Yahoo Developer Network
 
Hadoop Successes and Failures to Drive Deployment Evolution
Benoit Perroud
 
Hadoop World 2011: The Hadoop Stack - Then, Now and in the Future - Eli Colli...
Cloudera, Inc.
 
Introduction to hadoop and hdfs
TrendProgContest13
 
A Survey of Petabyte Scale Databases and Storage Systems Deployed at Facebook
BigDataCloud
 
Facebook keynote-nicolas-qcon
Yiwei Ma
 
Hadoop Summit 2012 | HBase Consistency and Performance Improvements
Cloudera, Inc.
 
Hadoop Ecosystem Overview
Gerrit van Vuuren
 
Apache Spark Overview part1 (20161107)
Steve Min
 
Hadoop 101
EMC
 
Hadoop Distributed File System Reliability and Durability at Facebook
DataWorks Summit
 
Common and unique use cases for Apache Hadoop
Brock Noland
 
Drill njhug -19 feb2013
MapR Technologies
 
Hadoop Tutorial for Beginners
business Corporate
 
Apachecon Euro 2012: Elastic, Multi-tenant Hadoop on Demand
Richard McDougall
 
Hadoop configuration & performance tuning
Vitthal Gogate
 

Viewers also liked (7)

PPTX
[Rakuten TechConf2014] [B-4] Rakuten Technology Conference Diversity session
Rakuten Group, Inc.
 
PDF
[RakutenTechConf2013] [A-3] TSUBAME2.5 to 3.0 and Convergence with Extreme Bi...
Rakuten Group, Inc.
 
PDF
ROMAについて
Rakuten Group, Inc.
 
PDF
楽天市場を取り巻く状況と開発
Rakuten Group, Inc.
 
PDF
The Egison Programming Language
Rakuten Group, Inc.
 
PPTX
[RakutenTechConf2013] [D-3_2] Counting Big Data by Streaming Algorithms
Rakuten Group, Inc.
 
PDF
Devsumi2012フィードバック オープニング
Rakuten Group, Inc.
 
[Rakuten TechConf2014] [B-4] Rakuten Technology Conference Diversity session
Rakuten Group, Inc.
 
[RakutenTechConf2013] [A-3] TSUBAME2.5 to 3.0 and Convergence with Extreme Bi...
Rakuten Group, Inc.
 
ROMAについて
Rakuten Group, Inc.
 
楽天市場を取り巻く状況と開発
Rakuten Group, Inc.
 
The Egison Programming Language
Rakuten Group, Inc.
 
[RakutenTechConf2013] [D-3_2] Counting Big Data by Streaming Algorithms
Rakuten Group, Inc.
 
Devsumi2012フィードバック オープニング
Rakuten Group, Inc.
 
Ad

Similar to ROMA User-Customizable NoSQL Database in Ruby (20)

PDF
IFRA Local Media Presentation: My Own City
Lassi Kurkijärvi
 
PDF
Distributed Systems in Data Engineering
Oluwasegun Matthew
 
KEY
Technical standards & the RDTF Vision: some considerations
Paul Walk
 
PDF
eBay’s Challenges and Lessons
hutuworm
 
PPT
ROMA -- An Customizable-NoSQL Database in Ruby at NoSQL Afternoon in Japan
Rakuten Group, Inc.
 
PDF
Litmus: RIA
Resource/Ammirati
 
PPTX
Scalability
felho
 
PDF
Keynote-Service Orientation – Why is it good for your business
WSO2
 
PPTX
Tech4Africa - Opportunities around Big Data
Steve Watt
 
PDF
Be My API How to Implement an API Strategy Everyone will Love
CA API Management
 
PPTX
Steve Watt Presentation
Big Data Houston
 
PDF
SOA an architecture on the Desktop
Vincent Perrin
 
PPTX
Introducing MongoDB into your Organization
MongoDB
 
PDF
NOSQLEU - Graph Databases and Neo4j
Tobias Lindaaker
 
PPTX
Zero to ten million daily users in four weeks: sustainable speed is king
plumbee
 
PPTX
Scalable Web Architecture and Distributed Systems
hyun soomyung
 
PDF
Transforming Software Architecture for the 21st Century (September 2009)
Dion Hinchcliffe
 
PDF
Service-Oriented Design and Implement with Rails3
Wen-Tien Chang
 
PPTX
Restfs
Manfred Furuholmen
 
PDF
Cloud is such stuff as dreams are made on
Patrick Chanezon
 
IFRA Local Media Presentation: My Own City
Lassi Kurkijärvi
 
Distributed Systems in Data Engineering
Oluwasegun Matthew
 
Technical standards & the RDTF Vision: some considerations
Paul Walk
 
eBay’s Challenges and Lessons
hutuworm
 
ROMA -- An Customizable-NoSQL Database in Ruby at NoSQL Afternoon in Japan
Rakuten Group, Inc.
 
Litmus: RIA
Resource/Ammirati
 
Scalability
felho
 
Keynote-Service Orientation – Why is it good for your business
WSO2
 
Tech4Africa - Opportunities around Big Data
Steve Watt
 
Be My API How to Implement an API Strategy Everyone will Love
CA API Management
 
Steve Watt Presentation
Big Data Houston
 
SOA an architecture on the Desktop
Vincent Perrin
 
Introducing MongoDB into your Organization
MongoDB
 
NOSQLEU - Graph Databases and Neo4j
Tobias Lindaaker
 
Zero to ten million daily users in four weeks: sustainable speed is king
plumbee
 
Scalable Web Architecture and Distributed Systems
hyun soomyung
 
Transforming Software Architecture for the 21st Century (September 2009)
Dion Hinchcliffe
 
Service-Oriented Design and Implement with Rails3
Wen-Tien Chang
 
Cloud is such stuff as dreams are made on
Patrick Chanezon
 
Ad

More from Rakuten Group, Inc. (20)

PDF
EPSS (Exploit Prediction Scoring System)モニタリングツールの開発
Rakuten Group, Inc.
 
PPTX
コードレビュー改善のためにJenkinsとIntelliJ IDEAのプラグインを自作してみた話
Rakuten Group, Inc.
 
PDF
楽天における安全な秘匿情報管理への道のり
Rakuten Group, Inc.
 
PDF
What Makes Software Green?
Rakuten Group, Inc.
 
PDF
Simple and Effective Knowledge-Driven Query Expansion for QA-Based Product At...
Rakuten Group, Inc.
 
PDF
DataSkillCultureを浸透させる楽天の取り組み
Rakuten Group, Inc.
 
PDF
大規模なリアルタイム監視の導入と展開
Rakuten Group, Inc.
 
PDF
楽天における大規模データベースの運用
Rakuten Group, Inc.
 
PDF
楽天サービスを支えるネットワークインフラストラクチャー
Rakuten Group, Inc.
 
PDF
楽天の規模とクラウドプラットフォーム統括部の役割
Rakuten Group, Inc.
 
PDF
Rakuten Services and Infrastructure Team.pdf
Rakuten Group, Inc.
 
PDF
The Data Platform Administration Handling the 100 PB.pdf
Rakuten Group, Inc.
 
PDF
Supporting Internal Customers as Technical Account Managers.pdf
Rakuten Group, Inc.
 
PDF
Making Cloud Native CI_CD Services.pdf
Rakuten Group, Inc.
 
PDF
How We Defined Our Own Cloud.pdf
Rakuten Group, Inc.
 
PDF
Travel & Leisure Platform Department's tech info
Rakuten Group, Inc.
 
PDF
Travel & Leisure Platform Department's tech info
Rakuten Group, Inc.
 
PDF
OWASPTop10_Introduction
Rakuten Group, Inc.
 
PDF
Introduction of GORA API Group technology
Rakuten Group, Inc.
 
PDF
100PBを越えるデータプラットフォームの実情
Rakuten Group, Inc.
 
EPSS (Exploit Prediction Scoring System)モニタリングツールの開発
Rakuten Group, Inc.
 
コードレビュー改善のためにJenkinsとIntelliJ IDEAのプラグインを自作してみた話
Rakuten Group, Inc.
 
楽天における安全な秘匿情報管理への道のり
Rakuten Group, Inc.
 
What Makes Software Green?
Rakuten Group, Inc.
 
Simple and Effective Knowledge-Driven Query Expansion for QA-Based Product At...
Rakuten Group, Inc.
 
DataSkillCultureを浸透させる楽天の取り組み
Rakuten Group, Inc.
 
大規模なリアルタイム監視の導入と展開
Rakuten Group, Inc.
 
楽天における大規模データベースの運用
Rakuten Group, Inc.
 
楽天サービスを支えるネットワークインフラストラクチャー
Rakuten Group, Inc.
 
楽天の規模とクラウドプラットフォーム統括部の役割
Rakuten Group, Inc.
 
Rakuten Services and Infrastructure Team.pdf
Rakuten Group, Inc.
 
The Data Platform Administration Handling the 100 PB.pdf
Rakuten Group, Inc.
 
Supporting Internal Customers as Technical Account Managers.pdf
Rakuten Group, Inc.
 
Making Cloud Native CI_CD Services.pdf
Rakuten Group, Inc.
 
How We Defined Our Own Cloud.pdf
Rakuten Group, Inc.
 
Travel & Leisure Platform Department's tech info
Rakuten Group, Inc.
 
Travel & Leisure Platform Department's tech info
Rakuten Group, Inc.
 
OWASPTop10_Introduction
Rakuten Group, Inc.
 
Introduction of GORA API Group technology
Rakuten Group, Inc.
 
100PBを越えるデータプラットフォームの実情
Rakuten Group, Inc.
 

Recently uploaded (20)

PDF
CIFDAQ Market Wrap for the week of 4th July 2025
CIFDAQ
 
PDF
Achieving Consistent and Reliable AI Code Generation - Medusa AI
medusaaico
 
PPTX
Webinar: Introduction to LF Energy EVerest
DanBrown980551
 
PDF
Fl Studio 24.2.2 Build 4597 Crack for Windows Free Download 2025
faizk77g
 
PDF
Smart Trailers 2025 Update with History and Overview
Paul Menig
 
PDF
HCIP-Data Center Facility Deployment V2.0 Training Material (Without Remarks ...
mcastillo49
 
PPTX
WooCommerce Workshop: Bring Your Laptop
Laura Hartwig
 
PDF
New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
PDF
Newgen Beyond Frankenstein_Build vs Buy_Digital_version.pdf
darshakparmar
 
PPTX
From Sci-Fi to Reality: Exploring AI Evolution
Svetlana Meissner
 
PDF
POV_ Why Enterprises Need to Find Value in ZERO.pdf
darshakparmar
 
PDF
Transcript: New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
PDF
From Code to Challenge: Crafting Skill-Based Games That Engage and Reward
aiyshauae
 
PDF
The Rise of AI and IoT in Mobile App Tech.pdf
IMG Global Infotech
 
PDF
CIFDAQ Token Spotlight for 9th July 2025
CIFDAQ
 
PPTX
COMPARISON OF RASTER ANALYSIS TOOLS OF QGIS AND ARCGIS
Sharanya Sarkar
 
PPTX
Q2 FY26 Tableau User Group Leader Quarterly Call
lward7
 
PDF
Biography of Daniel Podor.pdf
Daniel Podor
 
PDF
Blockchain Transactions Explained For Everyone
CIFDAQ
 
PDF
How Startups Are Growing Faster with App Developers in Australia.pdf
India App Developer
 
CIFDAQ Market Wrap for the week of 4th July 2025
CIFDAQ
 
Achieving Consistent and Reliable AI Code Generation - Medusa AI
medusaaico
 
Webinar: Introduction to LF Energy EVerest
DanBrown980551
 
Fl Studio 24.2.2 Build 4597 Crack for Windows Free Download 2025
faizk77g
 
Smart Trailers 2025 Update with History and Overview
Paul Menig
 
HCIP-Data Center Facility Deployment V2.0 Training Material (Without Remarks ...
mcastillo49
 
WooCommerce Workshop: Bring Your Laptop
Laura Hartwig
 
New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
Newgen Beyond Frankenstein_Build vs Buy_Digital_version.pdf
darshakparmar
 
From Sci-Fi to Reality: Exploring AI Evolution
Svetlana Meissner
 
POV_ Why Enterprises Need to Find Value in ZERO.pdf
darshakparmar
 
Transcript: New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
From Code to Challenge: Crafting Skill-Based Games That Engage and Reward
aiyshauae
 
The Rise of AI and IoT in Mobile App Tech.pdf
IMG Global Infotech
 
CIFDAQ Token Spotlight for 9th July 2025
CIFDAQ
 
COMPARISON OF RASTER ANALYSIS TOOLS OF QGIS AND ARCGIS
Sharanya Sarkar
 
Q2 FY26 Tableau User Group Leader Quarterly Call
lward7
 
Biography of Daniel Podor.pdf
Daniel Podor
 
Blockchain Transactions Explained For Everyone
CIFDAQ
 
How Startups Are Growing Faster with App Developers in Australia.pdf
India App Developer
 

ROMA User-Customizable NoSQL Database in Ruby

  • 1. ROMA User-Customizable NoSQL Database in Ruby Rakuten, Inc., Rakuten Institute of Technology | Masaya Mori 1
  • 2. Introduction • 森 正弥 (もり まさや) まさや) • 楽天株式会社 執行役員 • 楽天技術研究所 所長 • 職掌 Masaya Mori – 開発部署のマネジメント Twitter: @emasha – 研究開発の推進・統括 2
  • 3. Rakuten Institute of Technology Strategic R&D organization for Rakuten group Concept Tokyo & NY More Than Web - Your great reality through emerging technologies - Mission Turning emerging and growing new technology seeds into new business/service opportunities to enrich the internet life (& real life) all over the world 3
  • 4. Global R&D has begun. 30 in Tokyo & 10 in NY Tokyo New York 4
  • 5. Issues and our R&D area The internet has been growing to be diverse, huge, complicated and high-valued. • On basis of that, we progress three following R&D area to provide solution in the near future. Power Intelligence Reality ・Distributed computing ・Knowledge mining ・Multimedia Processing ・High performance computing ・NLP / Recommender ・Ubiquitous / next UI 5
  • 6. Unite, Contribution to Academia Data Ecosystem R&D symposium Post / publish Promote academic researchers to exploit Rakuten’s web public data Expected results ・share R&D with external researchers ・increase data & service awareness of people 6
  • 7. Agenda • Background • Features of ROMA • Overall architecture of ROMA • Plug-in architecture and its domain specific language • Conclusion 7
  • 8. Internet Service • User-driven service – Release is just a beginning. – As per user’s request, always Improve, always Advance. • Software runs on Sever side – Can change any time – Big gap between package software and server side application • Flexibility, Speed > Perfect – Lightweight Language • Ex. Ruby, Perl, Python, etc. – A.R.C. – Schema-less • CouchDB, MongoDB – Virtualization, Cloud 8
  • 9. Internet technology • Advantage of Open Source – Risk of vendor rock-on – Easy to start – Collective Inteligence, Collective Development • Simple & Loose – HTTP – REST + JSON > SOAP or EBXML or EJB – MySQL, memcached • Scalability – Load balancing – Cache – Distributed Cache – Disk I/O is always too slow 9
  • 10. High Performance • Importance of good performance – Amazon : 0.1s of latency -> down 1% sales – Google : 0.5s extra rending time -> drop 20% traffic – Generally, 1sec delay means .. • Down 11% Page Views • Down 7% Conversions • Down 16% Customer Satisfaction – Lost tens of millions yen by 5 minutes service down • To achieve high performance website – Reduce size of HTML, Javascript – Local Cache, Ajax – On memory solution with consistency – SSD > HDD – Less latency – GPGPU 10
  • 11. High availability • 24/7 – Downtime = Lose profit • Redundancy – Power – Network – Load balancer – BGP – RAID – Replication and Backup – Data Center – Operator • BCP for disaster – Big earchquake 11
  • 12. Big Data, the direction • New value from big data – Data mining – Suggestion, Recommendation – Personalization • Technology to deal with big data – Cassandra – Hadoop – Lucene + Solr Cloud – It’s referred to as NoSQL roughly. • Processing ex. MapReduce • Storing ex. KVS • Search – Answer within 0.1s from over 70 million items • BI – Can provide analyzed data to sales & marketing – Also provide tools reflecting knowledge of statics 12
  • 13. Storing: NoSQL databases • Needs for NoSQL databases are on the increase in order to easily store surging data • Basic features of several NoSQL databases are – High scalability – High availability – High throughput – Other features vary by databases • ROMA – Started development with Matz in 2007 – Open sourced in Oct. 2009 • See http://github.com/roma/roma/ 13
  • 14. ROMA Usage in Rakuten • ROMA is used in various Rakuten services – ROMA runs on dozens of servers – Various types of data are stored • E.g. session data, personal page view history, etc • Rakuten, Inc. – It provides many e-commerce platforms • E.g. Rakuten Ichiba, Rakuten Travel, Rakuten Books, etc – Rakuten has over 70 millions of users 14
  • 15. Application-Specific Needs • Many specific needs from application-side – These specific needs come from actual service development sites • For example, users say – “How can we store structured data?” • Not value, but…. Map? List? – “How can we easily process stored data on DWH or Hadoop?” – “How can we delete null character that was stored somewhere by error?” – “How can we delete duplicate data that were accidentally stored somewhere, maybe by bugs of app?” • We want to respond to all of these needs – We are trying to solve these problems, one by one. – Thereby, we hope we focus on what really matter on site. 15
  • 16. Case Study: List Operation in Rakuten Travel • “How can we easily access list data stored in ROMA?” – Request from Rakuten Travel to apply page view history using ROMA – Page view history function is useful function for users 16
  • 17. Case Study: List Operation in Rakuten Travel • The application stores list data for users in database – Key: user ID, Value: a list of pages that the user viewed • In such case as memcached, to delete list data stored in NoSQL database, application… 1. Gets binary data of specified key 2. Deserializes it as list data 3. delete the list data according to user requirement 4. Serializes the list data to binary data 5. Set it to database ① get binary data “delete 2nd elm into list” req ⑤ put binary data ② deserialize binary as list data Memcached cluster ③ delete 2nd elm into list ④ serialize list data to binary 17
  • 18. ROMA • User-customizable NoSQL database in Ruby • Features – Key-value model – High scalability – High availability – Fault-tolerance – Better throughput – And… • To meet application-specific needs, ROMA provides – Plug-in architecture – Domain specific language (DSL) for Plug-in • ROMA enables meeting the above need in Rakuten Travel 18
  • 19. Overall Architecture • ROMA integrates several well-known techniques to achieve scalability, availability and fault-tolerance – For example, consistent hashing, virtual nodes, chain replication-like mechanism, lamport clocks, etc • ROMA node consists of 4 modules – Network IO module: Receiving data from clients and other ROMA nodes – Command exec module: Creating and executing commands – Routing module: Maintaining ring information – Storage module: Storing data Network IO module Command Execution Routing module module Storage module 19
  • 20. Data Partitioning • Consistent hashing and virtual nodes – ROMA consists of several nodes that run on servers – Many virtual nodes are allocated on 1-dimensional hash space of 32-bits • Each virtual node has a 32-bits ID – To determine which ROMA node to store key in. – SHA-1 hash E.g. ROMA consists of three nodes ROMA 20
  • 21. Data Accessing • In getting value of specified key from ROMA 1. User accesses to ROMA nodes 2. The node determines others that are responsible for value of specified key 3. The node gets the value from the other node 4. The node returns it to user ① E.g. ROMA consists of three nodes ② ROMA 21
  • 22. Sharing routing table • Each node maintains and periodically shares routing table with others – Routing tables: range of hashs, machines, port – If several versions of routing table exist, node updates the latest version. – Lamport clocks and Merkle hash tree • ROMA node multicasts with others to share routing tables – We use multicast though being aware of scalability. – Current version of ROMA doesn’t use gossip-based protocol. E.g. ROMA consists of three nodes ROMA Sharing ring information 22
  • 23. Client has cache of routing table • ROMA client enables direct accessing to data – Client has a cache of routing table. – It checks to see if routing table is updated or not every 3 sec. • In getting value of specified key, ROMA client 1. Determines nodes according to cache 2. Gets the value from the node directly E.g. ROMA consists of three nodes ROMA 23
  • 24. Data Replication • Automatic data replication – Client waits until data replication finishes successfully. – If data replication failed, the data is push to asynchronous queue in node, which it will retry replication. – Eventual consistency • Each data is replicated at N nodes – N: this parameter is configured in advance E.g. ROMA consists of three nodes ROMA 24
  • 25. Message Protocol • Extended Memcached protocol over TCP – Used between clients and ROMA nodes • Memcached client libraries are also available. – Without distribution concern • User can access any node and ROMA forwards it later. – Users can use telnet. $ telnet localhost 11211 Trying 127.0.0.1... Connected to localhost. Escapecharacter is ‘^]’. set foo 0 0 3 bar User can set/get data in ROMA STORED with telnet like memcached get foo VALUE foo 0 3 bar END 25
  • 26. Failure Detection • Heartbeat detection – Each node multicasts periodic heartbeat with others – Heartbeat is flooded every 1 sec. • If heartbeat is missed continuously, the node is declared as failed – Failover – Removal of the node E.g. ROMA consists of three nodes ROMA Sending heartbeat 26
  • 27. Plug-in Architecture • Plug-ins allow users to extend behavior of ROMA • For example, – Command plug-ins enable to change behavior of command module – Users can append user-defined commands to ROMA – Current version provides plug-ins for command module only • Plug-ins for other modules coming soon • For example, storage-plug-in. Network IO module Command Execution Command Plug-ins Routing module module Storage module 27
  • 28. Case Study: Commands for List Operations • ROMA allows defining commands for list operations as plug-ins – Users can atomically access list data stored in ROMA as value ① get binary data “delete 2nd elm into list” req ⑤ put binary data ② de-serialize binary data ③ delete 2nd elm into list Memcached cluster ④ serialize list data delete 2nd elm into list data “delete 2nd elm into list” req ROMA 28
  • 29. Case Study: Commands for List Operations # alist_insert <key> <index> <bytes> [forward]¥r¥n # <data block>¥r¥n # # (STORED|NOT_STORED|SERVER_ERROR <error message>)¥r¥n def ev_alist_insert(s) hname, k, d, vn, nodes = calc_hash(s[1]) data = read_bytes(s[3].to_i); read_bytes(2) return forward2(nodes[0], s, data) if nodes[0] != @nid Method declaration ddata = @storages[hname].get(vn, k, d) for list command v = [[], []] unless ddata named “alist_insert alist_insert” alist_insert v = Marshal.load(ddata) if ddata v[0].insert(s[2].to_i, data) v[1].insert(s[2].to_i, Time.now.to_i) expt = 0x7fffffff ret = @storages[hname].set(vn, k, d, expt, Marshal.dump(v)) @stats.write_count += 1 As for lines, like this. if ret redundant(nodes[1..-1], hname, k, d, ret[2], expt, ret[4]) User can use also send_data("STORED¥r¥n") Telnet. end send_data("NOT_STORED¥r¥n") unless ret end 29
  • 30. Command Plug-in Mechanism • Command exec module – Loads plug-in and registers plug-in method at startup • Plug-in method has method name starting with ev_ • For example, ev_alist_insert is plug-in method • Ruby allows adding new methods to classes dynamically – In calling plug-in method 1. Receives data from network IO module and creates new command 2. Finds registered plug-in method responding to the command 3. Calls plug-in method • Uses send method provided by Ruby. Network IO module Command Execution Command Plug-ins Routing module module Storage module 30
  • 31. DSL for Command Plug-in • DSL enables users to simply declare commands – Without distribution concern (data replication, data partitioning) – def_write_command_with_key_value • Allows easily defining commands for storing structured data in ROMA • For example, – User can declare a alist_insert command with DSL # alist_insert <key> <index> <bytes> [forward]¥r¥n # <data block>¥r¥n # # (STORED|NOT_STORED|SERVER_ERROR <error message>)¥r¥n def_write_command_with_key_value :alist_insert, 3 do |ctx| v = [[], []] v = Marshal.load(ctx.stored.value) if ctx.stored v[0].insert(ctx.argv[2].to_i, ctx.params.value v[1].insert(ctx.argv[2].to_i, Time.now.to_i) expt = 0x7fffffff [0, expt, Marshal.dump(v), :write, 'STORED'] end 31
  • 32. Commands for Map Operations with DSL • Another example: User can declare map_set command with DSL – User can store map data in ROMA as value of specified key # map_set <key> <mapkey> <flags> <expt> <bytes>¥r¥n # <data block>¥r¥n # # (STORED|NOT_STORED|SERVER_ERROR <error message>)¥r¥n def_write_command_with_key_value :map_set, 5 do |ctx| v = {} v = Marshal.load(ctx.stored.value) if ctx.stored v[ctx.argv[2]] = ctx.params.value expt = ctx.argv[4].to_i if expt == 0 expt = 0x7fffffff elsif expt < 2592000 expt += Time.now.to_i end [0, expt, Marshal.dump(v), :write, 'STORED'] end 32
  • 33. DSL Mechanism • def_write_command_with_key_value is declared as method in Ruby def def_write_command_with_key_value(cmd, idx_of_val_len, forward = :one_line, &block) define_method "ev_#{cmd}" do |s| params = CommandParams.new params.key, params.hash_name = s[1].split("¥e") params.digest = Digest::SHA1.hexdigest(params.key).hex % @rttable.hbits params.vn = @rttable.get_vnode_id(params.digest) params.nodes = @rttable.search_nodes_for_write(params.vn) params.value = read_bytes(s[idx_of_val_len].to_i) read_bytes(2) stored = StoredData.new stored.vn, stored.last, stored.clk, stored.expt, stored.value = @storages[params.hash_name].get_raw(params.vn, params.key, params.digest) stored = nil if stored.vn == nil || Time.now.to_i > stored.expt ctx = CommandContext.new(s, params, stored) ret = instance_exec(ctx, &block) if ret redundant(ctx.params.nodes[1..-1], ctx.params.hash_name, ctx.params.key, ctx.params.digest, ret[2], expt, ret[4]) send_data("#{msg}¥r¥n") end send_data("NOT_#{msg}¥r¥n") unless ret end 33
  • 34. Conclusion • Background – Spread of NoSQL databases – application-specific needs • Features of ROMA – To respond to specific needs, ROMA provides user-customizable interfaces – Plug-in architecture and its domain specific language • Overall architecture of ROMA – It integrates several well-known techniques • Consistent hashing, chain replication-like mechanism, lamport clocks, etc • Plug-in architecture and DSL – Plug-ins allow enhancing behavior of ROMA easily 34
  • 35. Thank you for kindly attention 35