Idea about caching

If something doesn't fit in any other forum then post it here.
Forum rules
READ NOW: L2j Forums Rules of Conduct
Post Reply
Naminator_X_
Posts: 39
Joined: Thu Jun 10, 2010 9:06 am

Idea about caching

Post by Naminator_X_ »

Have you guys (core devs) ever thought of bundling memcached with L2J ? For those of you who don't know ... It is super fast caching system. It stores everything in the memory. It can store OBJECTS, ARRAYS, INTEGERS, STRINGS and all kind of stuff that java has to offer (read the java client). Most of it's code is done by Facebook and that is guarantee of hell of a lot optimized memory cache. After all facebook is running on PHP and i dont know if you know but on highly loaded sites its a beast to handle...especially with a 500 000 000 user base :D

I suggest you to check other features too that Facebook has developer. Faster read/write for hard disks on hard drives. This ... i bet this will speed up L2J A LOT !

Check this out aswell http://developers.facebook.com/opensource/
User avatar
poltomb
L2j Veteran
L2j Veteran
Posts: 225
Joined: Wed Jul 13, 2005 7:13 am
Location: USA

Re: Idea about caching

Post by poltomb »

I am not entirely sure if would be at all useful to our purpose. This is leaning more toward web developers (more specifically, web developers who are needing to handle large volumes of transactions per day). Also, since this is a PHP construct, we would need to handle marshalling the data and converting it into a form that php can handle. Not ideal. I highly doubt that this would help. For large scale transactional systems, it's great. Not so much for others.
Naminator_X_
Posts: 39
Joined: Thu Jun 10, 2010 9:06 am

Re: Idea about caching

Post by Naminator_X_ »

Umm memcached and FlashCache are not web based solutions only =)

I did some research and there is indeed a memcached client for java. Actually i've found 2.
http://github.com/gwhalin/Memcached-Java-Client
http://code.google.com/p/spymemcached/

Flash cache is more of a linux kernel tweak. Yup this will screw a bit with the crossplatform thingie but the benefits are... :X
DonDrakon
Posts: 23
Joined: Sun Oct 10, 2010 6:34 pm
Location: Ukraine Kiev

Re: Idea about caching

Post by DonDrakon »

post more info about your idea =)
You say about cacheing user info or about what?
User avatar
Stake
Posts: 383
Joined: Sun Mar 23, 2008 9:33 pm
Location: Hungary
Contact:

Re: Idea about caching

Post by Stake »

Naminator_X_ wrote:Umm memcached and FlashCache are not web based solutions only =)

I did some research and there is indeed a memcached client for java. Actually i've found 2.
http://github.com/gwhalin/Memcached-Java-Client
http://code.google.com/p/spymemcached/

Flash cache is more of a linux kernel tweak. Yup this will screw a bit with the crossplatform thingie but the benefits are... :X
In Java, I don't think, you can handle memory allocations like in C/C++. These allocations (cache) are handled by JRE process. Caching more than needed is not profitable.

Anyway, this memcache is more applicable for reading/writing files and collections. "Cache" is an excessive term for this situation. It is more like "buffering".
Image
Image
User avatar
poltomb
L2j Veteran
L2j Veteran
Posts: 225
Joined: Wed Jul 13, 2005 7:13 am
Location: USA

Re: Idea about caching

Post by poltomb »

From what I read, this is mostly about caching data that would normally take a database READ. How often does the database get read per suer session? Not nearly as often as the data is WRITTEN. This caching system is not that useful if the data is already in memory (which is where our data tables and currently connected clients are stored, so long as they are not paged to disk, and I have no idea how much this happens). Memcache is typically used as a data caching system for data often read from disk, not as a write buffer between the database and an application; it was not designed for that purpose.
Naminator_X_
Posts: 39
Joined: Thu Jun 10, 2010 9:06 am

Re: Idea about caching

Post by Naminator_X_ »

Yup memcached is designed to get data extremely fast with multiple concurency on a single thread ! I didn't knew how the server works in the background but from all guides i've read it appeared (at least to me) that it requires strong database server. I'm working as a web developer (that is why you thought i gave you only web based solutions :D ) and i know what it is to have regular computer load of 2-3 just because of the database on a server that is Core-i7 powered :) (that's linux's "top" load information...)

Well thanks for the info poltomb.

P.S> In my experience we use memcached to save SQL queries. It's really simple. We have...what it is called in php....a helper function..which is..lets say...getUserInfo(userId) that helper function checks if there is a mecache key userId.user then we read it and throw it back to the main script if not we send the query in transaction so it locks the row until the query is finished. Then the output is cached and sent back to the main script and voila -> next time you call that helper function you read the cache...unless of course it has expired or it have been invalidated somewhere else in the script.

So far it's pretty stable. We have around 25-30 caches per page refresh for single user and we have like 3000 online user base like all the time and it is working like a charm. And the funny thing is...memcached is never to be seen in "top" process list :O it's extremely lightweight
_DS_
L2j Veteran
L2j Veteran
Posts: 3437
Joined: Wed Apr 30, 2008 8:53 am
Location: Russia

Re: Idea about caching

Post by _DS_ »

SQL load quite high during loading of new chars during login and during periodic data save. Both of those procedures can't be cached.
Commiter of the shit
public static final int PI = 3.1415926535897932384626433832795;
User avatar
JIV
L2j Veteran
L2j Veteran
Posts: 1882
Joined: Sun Jan 06, 2008 8:17 pm
Location: Slovakia
Contact:

Re: Idea about caching

Post by JIV »

l2j use custom caching for some stuff which matter.
Naminator_X_
Posts: 39
Joined: Thu Jun 10, 2010 9:06 am

Re: Idea about caching

Post by Naminator_X_ »

_DS_ wrote:SQL load quite high during loading of new chars during login and during periodic data save. Both of those procedures can't be cached.
Damn i though L2j is saving data real time :O by real time you should understand that i thought when i do something you send an UPDATE query to the database. You've found nice solution to the problem =)
User avatar
poltomb
L2j Veteran
L2j Veteran
Posts: 225
Joined: Wed Jul 13, 2005 7:13 am
Location: USA

Re: Idea about caching

Post by poltomb »

Naminator_X_ wrote:
_DS_ wrote:SQL load quite high during loading of new chars during login and during periodic data save. Both of those procedures can't be cached.
Damn i though L2j is saving data real time :O by real time you should understand that i thought when i do something you send an UPDATE query to the database. You've found nice solution to the problem =)
yes, data is only stored periodically and on char disconnect. This saves us from needing an enterprise level system to run modest sized servers while giving us a comfortable level of data integrity.
User avatar
JIV
L2j Veteran
L2j Veteran
Posts: 1882
Joined: Sun Jan 06, 2008 8:17 pm
Location: Slovakia
Contact:

Re: Idea about caching

Post by JIV »

items, quests are saved real time, others are not needed.
Post Reply