Akka Persistence and Kryo serialization

315 views
Skip to first unread message

Richard Bowker

unread,
Nov 20, 2014, 10:25:05 AM11/20/14
to akka...@googlegroups.com
I thought I'd experiment with using akka-kryo serializer to see what difference it made to performance of persisting an event (defined by a simple case class) compared to just allowing the default java serialization

after trying to follow the instructions in here https://github.com/romix/akka-kryo-serialization I am stuck.

it appears to serialize the class I wanted (as I can see it in the database), but on recovery of the actor I just get

"RecoveryFailure was caused by: com.esotericsoftware.kryo.KryoException: Encountered unregistered class ID: 1636190130 (akka.actor.ActorKilledException)"

have I just got a setting wrong, or am I doing it all wrong! :)

thank you!

Rich


here are the relevant sections of the application.conf..


akka {
extensions = ["com.romix.akka.serialization.kryo.KryoSerializationExtension$"]

actor {
serializers {  
kryo = "com.romix.akka.serialization.kryo.KryoSerializer"  
}   
serialization-bindings {
"com.example.State$DomainEvent" = kryo
}
}
}

kryo  {  
    # Possibles values for type are: graph or nograph  
    # graph supports serialization of object graphs with shared nodes  
    # and cyclic references, but this comes at the expense of a small overhead  
    # nograph does not support object grpahs with shared nodes, but is usually faster   
    type = "nograph"  


    # Possible values for idstrategy are:  
    # default, explicit, incremental  
    #  
    # default - slowest and produces bigger serialized representation. Contains fully-  
    # qualified class names (FQCNs) for each class. Note that selecting this strategy 
    # does not work in version 0.3.2, but is available on master and from 0.3.3 onward.
    #  
    # explicit - fast and produces compact serialized representation. Requires that all  
    # classes that will be serialized are pre-registered using the "mappings" and "classes"
    # sections. To guarantee that both sender and receiver use the same numeric ids for the same  
    # classes it is advised to provide exactly the same entries in the "mappings" section   
    #  
    # incremental - fast and produces compact serialized representation. Support optional  
    # pre-registering of classes using the "mappings" and "classes" sections. If class is  
    # not pre-registered, it will be registered dynamically by picking a next available id  
    # To guarantee that both sender and receiver use the same numeric ids for the same   
    # classes it is advised to pre-register them using at least the "classes" section   

    idstrategy = "explicit"  

    # Define a default size for serializer pool
    # Try to define the size to be at least as big as the max possible number
    # of threads that may be used for serialization, i.e. max number
    # of threads allowed for the scheduler
    serializer-pool-size = 16

    # Define a default size for byte buffers used during serialization   
    buffer-size = 4096  

    # The serialization byte buffers are doubled as needed until they exceed max-buffer-size and an exception is thrown. Can be -1 for no maximum.
    max-buffer-size = -1

    # If set, akka uses manifests to put a class name
    # of the top-level object into each message
    use-manifests = false

    # Enable transparent compression of serialized messages
    # accepted values are: off | lz4 | deflate
    compression = off

    # Log implicitly registered classes. Useful, if you want to know all classes
    # which are serialized. You can then use this information in the mappings and/or 
    # classes sections
    implicit-registration-logging = false 

    # If enabled, Kryo logs a lot of information about serialization process.
    # Useful for debugging and lowl-level tweaking
    kryo-trace = true

    # If proviced, Kryo uses the class specified by a fully qualified class name
    # to perform a custom initialization of Kryo instances in addition to what
    # is done automatically based on the config file.
    #kryo-custom-serializer-init = "CustomKryoSerializerInitFQCN"

    # Define mappings from a fully qualified class name to a numeric id.  
    # Smaller ids lead to smaller sizes of serialized representations.  
    #  
    # This section is mandatory for idstartegy=explciit  
    # This section is optional  for idstartegy=incremental  
    # This section is ignored   for idstartegy=default  
    #   
    # The smallest possible id should start at 20 (or even higher), because
    # ids below it are used by Kryo internally e.g. for built-in Java and 
    # Scala types   
    mappings {  
        "com.example.State$DomainEvent" = 20
    }  

    # Define a set of fully qualified class names for   
    # classes to be used for serialization.
    # The ids for those classes will be assigned automatically,
    # but respecting the order of declaration in this section  
    #  
    # This section is optional  for idstartegy=incremental  
    # This section is ignored   for idstartegy=default  
    # This section is optional  for idstartegy=explicit  
    classes = [
"com.example.State$DomainEvent"
    ]
}

Evgeniy Ostapenko

unread,
Nov 21, 2014, 9:46:45 AM11/21/14
to akka...@googlegroups.com
idstrategy = "default"  

четверг, 20 ноября 2014 г., 18:25:05 UTC+3 пользователь Richard Bowker написал:

Konrad Malawski

unread,
Nov 21, 2014, 9:54:28 AM11/21/14
to Akka User List
Hey guys,
I just skimmed it, but it seems Evgeniy's suggestion should help.
If you want it to be explicit you'd have to list all messages, including ActorKilledException in the classes section it seems...

Let us know if that solved the problem - may be useful for other hakkers!

--
>>>>>>>>>> Read the docs: http://akka.io/docs/
>>>>>>>>>> Check the FAQ: http://doc.akka.io/docs/akka/current/additional/faq.html
>>>>>>>>>> Search the archives: https://groups.google.com/group/akka-user
---
You received this message because you are subscribed to the Google Groups "Akka User List" group.
To unsubscribe from this group and stop receiving emails from it, send an email to akka-user+...@googlegroups.com.
To post to this group, send email to akka...@googlegroups.com.
Visit this group at http://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.



--
Cheers,
Konrad 'ktoso' Malawski
hAkker @ Typesafe

Richard Bowker

unread,
Nov 24, 2014, 4:54:40 AM11/24/14
to akka...@googlegroups.com
Thank you for the suggestions, unfortunately no, setting it to default didn't seem to make any difference

Roman Levenstein

unread,
Nov 26, 2014, 1:24:34 AM11/26/14
to akka...@googlegroups.com
Hi Rich,

I'm the author of akka-kryo-serialization. Sorry for a very delayed response. I'm pretty busy at my daily job these days.

I'l try to look into this issue. It would be very helpful, if you could file akka-kryo-serialization issues using Github. And I'd appreciate if you could provide me with a self-contained (simplified) project which reproduces your problem, if possible. 

Thanks,
  Roman
Reply all
Reply to author
Forward
0 new messages