订阅所有JSP/Servlet的日志 订阅 | 这是最新一篇日志 上一篇 | 下一篇日志 下一篇 ]
JAVA技术

优化CMP性能 in Weblogic with Long-term Caching

附件
optimizingcmpperformance.gif(8.3 K)
 
切换到幻灯片模式

在Weblogic中长期Cache优化CMP性能

Optimizing CMP Performance in Weblogic with Long-term Caching


Not very popular choice for persistence nowadays, CMP still too often is only
readily available persistence framework in Enterprise environment. While not
as sexy as hibernate or href="http://www.ibatis.com/common/sqlmaps.html" target="_blank">SQL Maps, CMP 2.X implementation
in leading application servers such as BEA href="http://www.bea.com/framework.jsp?CNT=index.htm&FP=/content/products/server/" target="_blank">Weblogic offers
quite good solution for ORM problems. Beside there is a lots of developers
familiar with EJB and mature support from different tools from href="http://xdoclet.sourceforge.net" target="_blank">xdoclet to Eclipse href="http://eclipse.org/webtools/index.html" target="_blank">wtp/jst.


Let's
take a look at what can be done to improve performance of CMP in Weblogic
by enabling more aggressive than default caching strategies.


Everybody knows that EJB Container maintains cache or pool of Entity Beans,
usually configurable in deployment descriptor. Amazingly lots of developers
don't realize that it doesn't mean that once Container loaded particular bean
instance from database it won't go to database again while bean instance is
kept in pool. Quite contrary, by default Container calls ejbLoad() to
synchronize instance's state from the database at the beginning of every transaction.
Basically on every operation with CMP bean, even if bean was loaded seconds
ago in previous transaction Container executes SQL select to refresh it. Only
while you operating with CMP instance(s) in one transaction Container caches
them. This is so called 'Commit Options A/B/C' as described in EJB 2.0 specification
(10.5.9).


Obviously reloading state from database in every transaction could have some
performance impact. Easy to understand why this is default behavior - this
is safest way if database shared between multiple processes and each one of
them could change state of persisted object in database while it's cached in
EJB pool. In this case we're facing possibility of lost updates - other process
updates record in database and then Container overwrites it with potentially
stale data from cache. But first of all refreshing data in the beginning of
transaction doesn't guarantee against lost updates, it's just reduces possibility
of it. This is a well know problem in database world and there are two approaches
to deal with it. First approach is so called 'pessimistic concurrency locking',
when records in database locked for other updaters for duration of transaction
('select for update'). This is almost never used because of significant overhead
and performance impact. Second approach is called 'optimistic concurrency locking',
in this case there is no actual locks held in database but process which execute
update has some mechanism to detect that record been updated by other process
between his read and update. Preferred way to implement this is with 'version'
column on the database table (in SQL update increment value for that column,
include previous value in 'where' clause and then detect if no rows are updated).


Weblogic has href="http://e-docs.bea.com/wls/docs81/ejb/entity.html#1168097" target="_blank">built in support
for optimistic concurrency in CMP beans
via href="http://e-docs.bea.com/wls/docs81/ejb/DDreference-cmp-jar.html#1114366" target="_blank">verify-columns element
in weblogic-cmp-rdbms-jar.xml deployment descriptor. It is a good practice
to have 'version' column in all (updatable) tables in your database and configure
CMPs to use it by enabling optimistic concurrency in href="http://e-docs.bea.com/wls/docs81/ejb/DDreference-ejb-jar.html#1113345" target="_blank">concurrency-strategy element
in weblogic-ejb-jar.xml


Optimistic concurrency alone doesn't give you any performance improvement,
but it's necessary step to enable href="http://e-docs.bea.com/wls/docs81/ejb/entity.html#1195723" target="_blank">cache-between-transactions functionality
which is not available without enabling optimistic concurrency (for the reasons
discussed above). Setting cache-between-transactions to 'true' will result
in Container skipping calls to ejbLoad() if bean instance is already
available in the EJB cache. For certain types of applications where the same
objects accessed more than once from different transactions over short period
of time this can lead to significant performance improvements (in our tests
up to 30% for our application).


Naturally your application must be ready to deal with OptimisticConcurrencyException when
concurrency violation is detected by container. When OptimisticConcurrencyException (subtype
of RuntimeException) is thrown Container discards EJB instance from cache.
In a cluster, when a bean with Optimistic concurrency is updated, notifications
are broadcast to other cluster members to prevent optimistic conflicts. Note
that if you have href="http://e-docs.bea.com/wls/docs81/ejb/DDreference-ejb-jar.html#1113474" target="_blank">delay-updates-until-end-of-tx set
to 'true' (default) your code won't see optimistic exception until transaction
commit.


Word of caution. While available for quite a long time, cache-between-transactions
functionality never worked stable in Weblogic 7, but it seems to be fixed in
version 8.1. We're using it in production applications and quite happy with
the results.






About the author




Dmitri Maximovich


Blog: http://www.jroller.com/page/maximdim


Dmitri Maximovich is an independent consultant specializing in software design, development, and technical training. He has more than twelve years of industry experience and has been involved with J2EE since its inception. His job profile includes designing and developing mission critical applications for financial and pharmaceutical industries.
Dmitri lives in Toronto, Canada and has a master's degree in Physics from St. Petersburg university.

平均得分
(0 次评分)





文章来自: TheServerSide
标签: cache 性能 优化 weblogic CMP 
评论: 18 | 查看次数: 3583
  • 共有 18 条评论
  • 1
  • 2
  • |
  • >>
beeflee [2009-10-13 13:35:33]
beeflee [2009-08-03 22:18:16]
beeflee [2009-06-09 12:37:33]
beeflee [2009-05-04 14:09:20]
beeflee [2009-04-19 21:13:28]
游客 [2009-01-09 17:46:11]
游客 [2009-01-08 14:32:18]
http://www.bestprog.com 出会いサイト-Lovers
http://www.interbd.com 出会い系サーチ
http://www.zappeduster.com 出会い系サイトFreedom
http://www.grupopenelope.com セフレPlaySpot
http://www.42plus.com メル友無料募集サイト
http://www.brv-inc.com 人妻がハマる出会い系
http://www.meditacija.net 不倫人妻秘密サークル
http://www.aec-dk.com/ ご近所の人妻探し
http://www.mb-friends.net/ セフレ伝説-セフレ探し専門サイト-
http://seo-mobi.net/jk/ 女子高生!
http://www.hmt-ag.com/ ご近所の出会い探し
http://www.biotechcgi.com/ 出会い放題
http://www.hi-tech-reno.com/ 素敵な恋人探し
http://www.mb-deai.net/ 人妻DX
http://www.littlediablo.net/ 出会いの森
http://www.ccc-p.com/ 出会い系オンリー
http://www.sit-n-shop.com/ メル友ちぇき!
http://www.mtdcases.com/ セフレステーション
http://www.louisville-realtor.com/ 人妻Magic!!
http://www.heartminders.com/ 不倫ありませんか!
http://www.targetvehiclerental.com/ ピンクの恋人
http://www.mail24x7.com/00/idkb0022.html プチ家出掲示板NO.1!リターンズ
http://www.kessel-diamonds.com スタビLuxury
http://sincerely-love.com/00 セックスフレンド無料サイト-プレミアム
http://www.cambridgeins.com/ セックスフレンド大陸
http://www.lots-ins.com/ ご近所のアイシテル!
http://www.chihuahuaelpub.com/ 出会い探し
http://www.aec-dk.com/merutomo/ ご近所のメル友探し
http://www.andritz-na.com/merutomo/ メル友を探そう
http://www.hi-tech-reno.com/merutomo/ 素敵なメル友探し
http://www.sugudeai.com/ 出会い系案内所
游客 [2008-11-18 19:51:55]
游客 [2008-10-17 14:34:57]
游客 [2008-09-24 09:49:39]
游客 [2008-09-02 15:46:47]
JWW
dofus kamas
kamas dofus
dofus kamas
kamas dofus
dofus kamas
kamas dofus
dofus kamas
kamas dofus
dofus kamas
kamas dofus
wow leveling
Runescape Money
Runescape Gold
Runescape Money
Runescape Gold
Runescape Power leveling
Runescape Money
Runescape Gold
Runescape gold
runescape money
Runescape Money
Runescape gold
Runescape Money
Runescape gold
Runescape Power leveling
Runescape Items
runescape money
runescape gold
money runescape
Runescape Money
Runescape gold
Runescape Gold
runescape money
age of conan gold
aoc power leveling
age of conan power leveling
aoc leveling
age conan gold
archlord gold
buy archlord gold
anarchy online credits
anarchy online credit
city of heroes influence
coh influence
city of villains infamy
cov infamy
dofus kamas
kamas dofus
eve isk
eve online isk
everquest 2 gold
eq2 plat
ffxi gil
final fantasy xi gil
buy ffxi gil
gaia online gold
gaia gold
guild wars gold
gw gold
hellgate london palladium
cabal alz
daoc gold
daoc plat
world of warcraft gold
wow po
wow or
buy wow gold
cheap wow gold
wow power leveling
wow powerleveling


world of warcraft gold
wow po
wow or
cheap wow gold
wow power leveling
wow powerleveling
buy wow gold
dofus kamas
kamas dofus
Lord of the Rings Online Gold
LOTRO Gold
LOTR Gold
age of conan gold
age conan gold
age of conan power leveling
aoc gold
aoc power leveling
aoc leveling
Maple Story meso
Maple Story Mesos
maplestory Mesos
fly for fun penya
flyff penya
buy flyff gold
flyff money
Final Fantasy XI gil
ffxi gil
buy ffxi gil
buy Warhammer gold
Warhammer gold
silkroad online gold
SRO gold
Silkroad gold
buy silkroad gold


world of warcraft gold
wow gold kaufen
buy wow gold
wow geld
cheap wow gold
wow power leveling
wow powerleveling
dofus kamas
kamas dofus
Lord of the Rings Online gold
LOTR gold
LOTRO gold
age of conan gold
age conan gold
age of conan power leveling
aoc gold
aoc power leveling
aoc leveling
Maple Story meso
Maple Story Mesos
maplestory Mesos
fly for fun penya
flyff penya
buy flyff gold
flyff money
Final Fantasy XI gil
ffxi gil
buy ffxi gil
buy Warhammer gold
Warhammer gold
silkroad online gold
SRO gold
Silkroad gold
buy silkroad gold


world of warcraft gold
wow po
wow or
buy wow gold
cheap wow gold
wow power leveling
wow powerleveling
dofus kamas
kamas dofus
Lord of the Rings Online Gold
LOTRO Gold
LOTR Gold
age of conan gold
age conan gold
age of conan power leveling
aoc gold
aoc power leveling
aoc leveling
Maple Story meso
Maple Story Mesos
maplestory Mesos
fly for fun penya
flyff penya
buy flyff gold
flyff money
ffxi gil
Final Fantasy XI gil
buy ffxi gil
silkroad online gold
SRO gold
Silkroad gold
buy silkroad gold
buy Warhammer gold
Warhammer gold


world of warcraft gold
wow po
wow or
buy wow gold
cheap wow gold
wow power leveling
wow powerleveling
dofus kamas
kamas dofus
Lord of the Rings Online Gold
LOTRO Gold
LOTR Gold
age of conan gold
age of conan power leveling
age conan gold
aoc gold
aoc power leveling
aoc leveling
Maple Story meso
Maple Story Mesos
maplestory Mesos
fly for fun penya
flyff penya
buy flyff gold
flyff money
ffxi gil
buy ffxi gil
Final Fantasy XI gil
buy cheap ffxi gil
buy Warhammer gold
Warhammer gold
silkroad online gold
SRO gold
Silkroad gold
buy silkroad gold




world of warcraft gold
wow po
wow or
buy wow gold
cheap wow gold
wow power leveling
wow powerleveling
dofus kamas
kamas dofus
Lord of the Rings Online Gold
LOTRO Gold
LOTR Gold
age of conan gold
age conan gold
age of conan power leveling
aoc gold
aoc power leveling
aoc leveling
Maple Story meso
Maple Story Mesos
maplestory Mesos
fly for fun penya
flyff penya
buy flyff gold
flyff money
ffxi gil
buy ffxi gil
Final Fantasy XI gil
buy cheap ffxi gil
buy Warhammer gold
Warhammer gold
silkroad online gold
SRO gold
Silkroad gold
buy Silkroad gold
游客 [2008-09-02 15:45:29]
JWW
The joyous Mid-Autumn Festival was celebrated on the fifteenth day ffxi gilof the eighth moon, around the time of the autumn equinox. Many referred to it simply as the "Fifteenth of the Eighth Moon".
This day was also considered as wow golda harvest festival since fruits, vegetables aoc goldand grain had been harvested by this time and food was abundant.
Food offerings were placed on an altar set up in the courtyard. Apples, pears, peaches, wow goldgrapes, pomegranates, melons, oranges and pomelos might be seen. Special foods for
maple story mesosthe festival included moon cakes, cooked taro and water caltrope, a type of water chestnut maplestory mesosresembling black buffalo horns.
Some people insistedmaple story meso that cooked taro be included because at the time of creation, taro was the first food discovered at night in the moonlight. Of allthese foods, it could not
be omitted from wow goldthe Mid-Autumn Festival.The round moon cakes, measuring about three inches in diameter and one and a half aoc goldinches in thickness,
resembled Western fruitcakes in taste and consistency. These wow goldcakes were made with melon seeds, lotus seeds, almonds, minced meats, bean wow goldpaste,
orange peels and lard. A golden yolk from a salted duck egg was placed at the wow goldcenter of each cake, and the golden brown crust was decorated with symbols of the festival. Traditionally,
thirteen moon cakes were piled in a pyramid to symbolize the thirteen moons of a "complete year," that is, twelve moons plus one intercalary moon. The Mid-Autumn Festival is a traditional wow goldfestivity
for both the Han and minority nationalities. The custom of worshipping the moon can be traced back as far as the ancient Xia wow goldand Shang Dynasties (2000 B.C.-1066 B.C.). In the Zhou Dynasty(1066 B.C.-221 B.C.),
people hold ceremonies to greet winter and worship the moon whenever the Mid-Autumn Festival sets in. It becomes very wow goldprevalent in the Tang Dynasty(618-907 A.D.) that people enjoy and worship the full moon.
In the Southern Song wow goldDynasty (1127-1279 A.D.), however, people send round moon cakes to their relatives as gifts in expression of their best wishes of wow goldfamily reunion.
When it becomes dark, they look up at the full silver moon or go sightseeing on lakes to celebrate the festival. Since the Ming (1368-1644 A.D. ) and Qing Dynasties (1644-1911A.D.), thewow gold custom of Mid-Autumn
Festival celebration becomes unprecedented popular. Together with the celebration there appear some special wow goldcustoms in different parts of the country, such as burning incense, planting Mid-Autumn trees, lighting
lanterns on towers and fire dragon dances. However, the custom of playing under the moon is not so popular as it used to be nowadays, but it is not less popular to enjoy the bright silver moon. Whenever the festival sets in, people will look up at
the wow goldfull silver moon, drinking wine to celebrate their happy life or thinking of their relatives and friends far from home,and extending all of their best wishes to them.
游客 [2008-09-02 10:44:07]
游客 [2008-09-02 10:43:23]
游客 [2008-08-07 13:59:12]
  • 共有 18 条评论
  • 1
  • 2
  • |
  • >>
发表评论
昵 称:  登录
内 容:
选 项:
字数限制 1000 字 | UBB代码 开启 | [img]标签 开启